Welcome to my collection of commonly used regular expressions! This repository is a handy resource for developers and anyone dealing with text pattern matching. Regular expressions (regex) are powerful tools for string manipulation and validation. This repository contains a collection of regular expressions I have found useful. I hope you find them useful too!
The primary purpose of this repository is to provide a curated list of regular expressions that I frequently use in various projects. Whether you are validating user inputs, searching for specific patterns in text, or parsing data, these regex patterns can be a valuable addition to your toolkit.
- Clone the repository with the following command:
git clone https://github.com/BrenoFariasdaSilva/Regular-Expressions.git
cd Regular-Expressions
A regex for validating email addresses, checking for the basic structure of an email, including '@' and domain extensions.
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Validate URLs with this regex, checking for the basic structure, including the protocol, domain name, and optional path.
^(http|https):\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(\/[a-zA-Z0-9%_.-]+\/?)*$
This regex validates dates in the format DD/MM/YYYY, checking for leap years and the correct number of days in each month.
^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/(19|20)\d{2}$
This regex validates usernames with the following criteria:
-
Minimum 3 characters.
-
Maximum 16 characters.
-
Only letters, numbers, underscores and hyphens.
^[a-zA-Z0-9_-]{3,16}$
This regex validates passwords with the following criteria:
-
Minimum 8 characters.
-
At least one uppercase letter.
-
One lowercase letter.
-
One number.
-
One special character.
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
This regex validates Brazilian CPFs, checking for the correct number of digits and the correct check digits.
^\d{3}\.\d{3}\.\d{3}-\d{2}$
This regex validates Brazilian zip codes, checking for the correct number of digits.
^\d{5}-\d{3}$
This regex validates Brazilian phone numbers, checking for the correct number of digits and the correct area code.
^\(\d{2}\) \d{4,5}-\d{4}$
This regex helps identify SQL injection attempts, checking for the most common SQL injection keywords.
(\b(?:SELECT|INSERT|UPDATE|DELETE|DROP|CREATE|ALTER)\b|\b(?:UNION|JOIN|WHERE|FROM)\b|\b(?:AND|OR|NOT)\b)
This regex validates IPv4 addresses, checking for the correct number of octets and the correct range of numbers in each octet.
^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$
This regex validates IPv6 addresses, checking for the correct number of hextets and the correct range of numbers and letters in each hextet.
^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$
This regex helps identify comments in a file with double spaces after the comment character, ensuring proper formatting.
\S[ ]{2}#
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. If you have suggestions for improving the code, your insights will be highly welcome. In order to contribute to this project, please follow the guidelines below or read the CONTRIBUTING.md file for more details on how to contribute to this project, as it contains information about the commit standards and the entire pull request process. Please follow these guidelines to make your contributions smooth and effective:
-
Set Up Your Environment: Ensure you've followed the setup instructions in the Setup section to prepare your development environment.
-
Make Your Changes:
- Create a Branch:
git checkout -b feature/YourFeatureName
- Implement Your Changes: Make sure to test your changes thoroughly.
- Commit Your Changes: Use clear commit messages, for example:
- For new features:
git commit -m "FEAT: Add some AmazingFeature"
- For bug fixes:
git commit -m "FIX: Resolve Issue #123"
- For documentation:
git commit -m "DOCS: Update README with new instructions"
- For refactorings:
git commit -m "REFACTOR: Enhance component for better aspect"
- For snapshots:
git commit -m "SNAPSHOT: Temporary commit to save the current state for later reference"
- For new features:
- See more about crafting commit messages in the CONTRIBUTING.md file.
- Create a Branch:
-
Submit Your Contribution:
- Push Your Changes:
git push origin feature/YourFeatureName
- Open a Pull Request (PR): Navigate to the repository on GitHub and open a PR with a detailed description of your changes.
- Push Your Changes:
-
Stay Engaged: Respond to any feedback from the project maintainers and make necessary adjustments to your PR.
-
Celebrate: Once your PR is merged, celebrate your contribution to the project!
This project is licensed under the Creative Commons Zero v1.0 Universal, which means you are free to use, modify, and distribute the code. See the LICENSE file for more details.