The most common regular expressions programmers should know (part 1)

Tram Ho

A regular expression (or regex ) is an advanced string processing technique through one or more strings of characters specially arranged based on a set of rules of a regular expression ( regex ).

Regex is quite difficult to access at first, it will take quite a while to remember and familiarize itself with its rules, but it will become an extremely powerful tool when you use it properly. body.

So, in this article I decided to create a sery to share with you guys who will use regex . In this first article, I will introduce you the first 10 expressions in this series

1. Check your email address

Checking email addresses is one of the most common tasks when developing software.

2. Verify the date is in the format (MM / DD / YYYY) / (MM-DD-YYYY) / (MM.DD.YYYY) / (MM DD YYYY)

3. Password strength

The above regex will force a string to:

  • contains a lowercase letter, a capital letter, a number, a special character in the number: [email protected] #$%^&?
  • an uppercase character
  • some
  • a special character of: [email protected] #$%^&?
  • At least 6 characters long

4. check the Hex color code

5. Check the url

6. Address ip4

7. IP6 address

9. If a string is written as an html tag

10. Find repeated words

Share the news now

Source : Viblo