This is a draft cheat sheet. It is a work in progress and is not finished yet.
Anchors
^ |
Start of line |
$ |
End of line |
\A |
Start of string |
\Z |
End of string |
\b |
Word bondary |
\B |
Not word bondary |
\< |
Start of word |
\> |
End of word |
Character Classes
\c |
Control character |
\s |
White space |
\S |
Not white space |
\d |
Digit |
\D |
Not digit |
\w |
Word |
\W |
Not word |
\hhh |
Hexadecimal digit |
\Oxxx |
Octal digit |
POSIX
[:upper:] |
Upper case |
[:lower:] |
Lower case |
[:alpha:] |
All letters |
[:alnum:] |
All lettres and digits |
[:digit:] |
All digits |
[:punct:] |
[!"\#$%&'()*+, \-./:;<=>?@\[ \\\]^_‘{|}~]
|
[:blank:] |
Space and Tab |
[:space:] |
Blank characters [ \t\r\n\v\f]
|
[:cntrl:] |
Control Characters [\x00-\x1F\x7F]
|
[:graph:] |
all except [:space:] and [:cntrl:] |
[:print:] |
all except [:cntrl:] |
[:word:] |
|
Assertions
?= |
Lookahead |
?! |
Negative lookahead |
?<= |
Lookbehind assertion |
?!= or ?<! |
negetive loockbehind |
?> |
Once-only subexpression |
?() |
Condition If then |
?()| |
Condition If then else |
Ex: test(?= word)
will match test only if it's followed by " word
". the match return will be test
string only
|
|
Quantifiers (match previous item x times)
* |
0 or more |
+ |
1 or more |
? |
0 or 1 |
{5} |
Exactly 5 |
{,5} |
0, 1, 2, 3, 4 and 5 |
{5,} |
5 or more |
{2,5} |
2, 3, 4 or 5 |
*? ,+?, ??, {2,5}? |
Same as above but lazy (match as few characters as possible) |
|
|
|