Show Menu
Cheatography

Regex Angel Cheat Sheet (DRAFT) by

Regex Cheat sheet to use and abuse it

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
Hexade­cimal 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-­\x1­F\x7F]
[:graph:]
all except [:space:] and [:cntrl:]
[:print:]
all except [:cntrl:]
[:word:]
[A-Za-­z0-9_]

Assertions

?=
Lookahead
?!
Negative lookahead
?<=
Lookbehind assertion
?!= or ?<!
negetive loockb­ehind
?>
Once-only subexp­ression
?()
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
 

Quanti­fiers (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)