Basic Syntax
|
Start and end regex delimiters |
|
Alternation |
|
Grouping |
Position Matching
|
Start of string or start of line in multi-line mode |
|
Start of string |
|
End of string or end of line in multi-line mode |
|
End of string |
|
Word boundary |
|
Not word boundary |
|
Start of word |
|
End of word |
Character Classes
|
Whitespace |
|
Not whitespace |
|
Word |
|
Not word |
|
Digit |
|
Not digit |
|
Hexadecimal digit |
|
Octal digit |
Special Characters
|
Newline |
|
Carriage return |
|
Tab |
|
Vertical tab |
|
Form feed |
|
Octal character xxx |
|
Hex character hh |
Groups and Ranges
|
Any character except newline (\n) |
|
a or b |
|
Group |
|
Passive (non-capturing) group |
|
a, b or c |
|
Not a, b or c |
|
Letters from a to z |
|
Uppercase letters from A to Z |
|
Digits from 0 to 9 |
Note: Ranges are inclusive. |
Quantifiers
|
0 or more |
|
1 or more |
|
0 or 1 |
|
Exactly 3 |
|
3 or more |
|
3, 4 or 5 |
Note: Quantifiers are greedy - they match as many times as possible. Add a |
Escape Sequences
|
Escape following character Used to escape any of the following metacharacters: |
|
Begin literal sequence |
|
End literal sequence |
String Replacement
|
1st group |
|
2nd group |
|
nth group |
|
Before matched string |
|
After matched string |
|
Last matched string |
|
Entire matched string |
Note: Some regex implementations use |
Assertions
|
Positive lookahead |
|
Negative lookahead |
|
Positive lookbehind |
|
Negative lookbehind |
|
Atomic (once-only) group |
|
Conditional (if a then match b) |
|
Conditional (if a then match b, else match c) |
|
Comment |
POSIX
|
Uppercase letters |
|
Lowercase letters |
|
All letters |
|
Digits and letters |
|
Digits |
|
Hexadecimal digits |
|
Punctuation |
|
Space and tab |
|
Blank characters |
|
Control characters |
|
Printed characters |
|
Printed characters and spaces |
|
Digits, letters and underscore |
Pattern Modifiers
|
Global match |
|
Case-insensitive |
|
Multi-line mode Causes |
|
Single-line mode. Causes |
|
Allow comments and whitespace in pattern |
|
Evaluate replacement |
|
Ungreedy mode |