| . ? + * ^ $ \ ( ) [ ] { } | |
Need to be escaped with a backslash (\) to match the actual character
|
| . | Matches one of any character
|
|||
| (...|...|...) | Matches one of the alternatives
|
| [abc] | Matches any character within the brackets (same as (a|b|c)) | |||
| [^abc] | Matches any character not between the brackets.
|
| \d | Matches digits (same as [0-9]) |
| \D | Matches non-digits (same as [^0-9]) |
| \w | Matches alphanumeric (same as [a-zA-Z0-9_]) |
| \W | Matches non-alphanumeric (same as [^a-zA-Z0-9_]) |
| \s | Matches whitespace |
| \S | Matches non-whitespace) |
| ^ | Matches the position at the beginning of the line |
| $ | Matches the position at the end of the line |
| \b | Matches the position between a \w\W or \W\w (word boundary)* |
| \B | Matches the position between a \w\w or \W\W (non-word boundary) |
* \b also matches at the beginning and end of a line
| ? | Match the previous element zero or one times (one if possible) | |||
| ?? | Match the previous element zero or one times (zero if possible) | |||
| + | Match the previous element one or more times (as many as possible) | |||
| +? | Match the previous element one or more times (as few as possible) | |||
| * | Match the previous element zero or more times (as many as possible)
|
|||
| *? | Match the previous element zero or more times (as few as possible) | |||
| {n} | Match the previous element exactly n times
|
|||
| {n,} | Match the previous element at least n times (as many as possible) | |||
| {n,}? | Match the previous element at least n times (as few as possible) | |||
| {n,m} | Match the previous element between n - m times (as many as possible) | |||
| {n,m}? | Match the previous element between n - m times (as few as possible) |
| (...) | Capture text matched between parentheses to an unnamed capture group. Unnamed capture groups (which are actually
numbered captures) can be referenced
in replace patterns.
|
| (?<foobar>...) | Capture text matched between parentheses to a named capture group called “foobar”. Named capture groups can be referenced in replace patterns. |
| (?=...) | Positive lookahead (match the position before the specified regex) |
| (?!...) | Negative lookahead (don’t match, as above) |
| (?<=...) | Positive lookbehind (match the position after the specified regex) |
| (?<!...) | Negative lookbehind (don't match, as above) |
| (?x) | Activate flag x |
| e.g. |
The search pattern '(?ix1)Fi' matches 'FI'
string in '123454321+FIVEfiveF'
The search pattern '(?ix2)Fi' matches 'FI' and 'fi' string in '123454321+FIVEfiveF'. |
Any text other than the variables below will be replaced as-is.
| \n | Match the text in unnamed capture group #n, captured earlier in the search pattern |
| \<foobar> | Match the text in named capture group “foobar”, captured earlier in the search pattern |