Best Reources:
- Interactive Regex Tutorial
- Best Youtube Tutorial Video
- Learn Regex the easy way
- Best Advice on the Internet
Practice:
You should always escape these characters: .[{()\^|?*+
Backslash is used to escape characters
For Example:
. - selects everything
\. - matches literal dot
You have to also escape a backslash itself i.e. \\ will result in \
Key | Meaning |
---|---|
. |
Any character except new line |
\d |
Digit (0-9) |
\D |
Not a Digit (0-9) |
\w |
Word Characters (a-z, A-Z, 0-9) |
\W |
Not a word character |
\s |
Whitespace (space, tab, newline) |
\S |
Not Whitespace (space, tab, newline) |
Key | Meaning |
---|---|
\b |
Word boundary |
\B |
Not a word boundary |
^ |
Beginning of a string |
$ |
End of a string |
Key | Meaning |
---|---|
[ ] |
Matches characters in brackets |
[^ ] |
Matches characters NOT in brackets |
| |
Either Or |
() |
Group |
Key | Meaning |
---|---|
* |
0 or more |
+ |
1 or more |
? |
0 or one |
{3} |
exact number |
{3,4} |
range of numbers (minimum, maximum) |