regex
Anchors
Symbol | Meaning |
---|---|
^ | Start of string, or start of line in multi-line pattern |
\A | Start of string |
$ | End of string, or end of line in multi-line pattern |
\Z | End of string |
\b | Word boundary (start of word) |
\B | Not word boundary |
\< | Start of word |
\> | End of word |
Quantifiers
Greedy | Lazy | Meaning |
---|---|---|
* | *? | 0 or more |
+ | +? | 1 or more |
? | ?? | 0 or 1 |
{3} | {3}? | exactly 3 |
{3,} | {3,}? | 3 or more |
{3,5} | {3,5}? | 3, 4 or 5 |
Character Classes
Symbol | Meaning |
---|---|
\c | Control character |
\s | white space |
\S | not white space |
\d | digit |
\D | not digit |
\w | word |
\W | not word |
\x | hex digit |
\o | octal digit |
special characters
Symbol | Meaning |
---|---|
\n | new line |
\r | carriage return |
\t | tab |
\v | vertical tab |
\f | form feed |
\xxx | octal character xx |
\xhh | hex character hh |
Groups and Ranges
Symbol | Meaning |
---|---|
. | Any character except new line (\n) |
(a|b) | a or b |
[abc] | range (a or b or c) |
[^abc] | not(a or b or c) |
[a-q] | letters a to q |