Giter Site home page Giter Site logo

regular-expressions's Introduction


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!


GitHub Code Size in Bytes Badge GitHub Last Commit Badge GitHub License Badge Wakatime Badge

RepoBeats Statistics

Table of Contents

Introduction

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.

Setup

Clone the repository

  1. Clone the repository with the following command:
git clone https://github.com/BrenoFariasdaSilva/Regular-Expressions.git
cd Regular-Expressions

Contents

1. Email Address

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,}$

2. URL (HTTP/HTTPS)

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%_.-]+\/?)*$

3. Date (DD/MM/YYYY) Format

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}$

4. Username

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}$

5. Password Strength

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,}$

6. CPF (Brazil)

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}$

7. Zip Code (Brazil)

This regex validates Brazilian zip codes, checking for the correct number of digits.

^\d{5}-\d{3}$

8. Phone Number (Brazil)

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}$

9. SQL Injection

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)

10. IPv4 Address

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}$

11. IPv6 Address

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}$

12. Comments with Double Spaces

This regex helps identify comments in a file with double spaces after the comment character, ensuring proper formatting.

\S[ ]{2}#

Contributing

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:

  1. Set Up Your Environment: Ensure you've followed the setup instructions in the Setup section to prepare your development environment.

  2. 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"
    • See more about crafting commit messages in the CONTRIBUTING.md file.
  3. 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.
  4. Stay Engaged: Respond to any feedback from the project maintainers and make necessary adjustments to your PR.

  5. Celebrate: Once your PR is merged, celebrate your contribution to the project!

License

Creative Commons Zero v1.0 Universal

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.

regular-expressions's People

Contributors

brenofariasdasilva avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.