| \d - Digit (0-9) . – Any Character except new line |
| \D - Not a Digit (0-9) |
| \w - Word Character (a-z, A-Z, 0-9, _) |
| \W - Not a Word Character |
| \s - White space (space, tab, newline) |
| \S - Not White space (space, tab, newline) |
| \b - Word Boundary |
| \B - Not a Word Boundary |
| ^ - Beginning of a String |
| $ - End of a String |
| [] - Matches Characters in brackets |
| [^ ] - Matches Characters NOT in brackets |
| | - Either Or |
| ( ) - Group |
Quantifiers: |
| * - 0 or More |
| + - 1 or More |
| ? - 0 or One |
| {3} - Exact Number |
| {5,10} - Range of Numbers (Minimum, Maximum) |
Sample Regex |
| [a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+ The above given characters make up a regular expression and using combinations of these expression we can match patterns or strings. |
Regular Expressions - I
A regular expression (shortened as regex) is an extremely useful way of matching common patterns and texts such as emails, phone numbers, URLs etc. almost all programming languages have a regular expressions library. It is widely used in text editors also to find patterns and replace string patterns that we specify in the find and replace tool.
In Regular expression there are many special characters that has a special meaning to the regular expression library in the compiler.