Syntax example:
/expression/
Good resource to training skills in regular expressions regexr.com or regex101.com
Special symbols:
- \w - letters with numbers
- \W - special symbols
- \d - digits
- \D - not digits
- \s - space
- \S - not spaces
- ^ - start of the line
- $ - end of the line
- (x|y) - this or this
- [1-9] - range
- [^1] - denial (all except 1)
- \w+ - letters from 1 to infinity
- \w{1,10} - from 1 to 10 letters
- and others
Match email:
/^\w+@\w+.\w+/
Match phone number:
/^\+\d{2,3}\s\d{3}\s\d{3}\s\d{1,3}/
Find file name with .js or .ts extension:
/\w+\.(j|t)s/
Set range for numbers:
/[0-9]/
Except 'w' letter:
/([^w])/