You are on page 1of 5

Regular Expressions Cheat Sheet

by Dave Child (DaveChild) via cheatography.comtlics/5/

Cheatography
Anchors Assertions

A Start of string, or start of line in multi- ?= Lookahead assertion

line pattern ?! Negative lookahead

\A Start of string ?<= Lookbehind assertion


End of string, or end of line in multi-line
$ ?!= or ?<! Negative lookbehind
pattern
?> Once-only Subexpression
\Z End of string
?() Condition [if then]
Word boundary
Condition [if then else]
\B Not word boundary
?# Comment
\< Start of word

\> End of word Quantifiers

re
{3}
re
{3,}
13
{3,
5}
ifie
r to

Se
qu

owi
ng
lite
ral
lite
se
ral
yse
of
eci
tre
al
me
y,
rat
ara
cte
n
Me
tac

ch
ara
al
Ch
ara
Ne
w
rria
line
ge
ret
Ta
b
tica
l
m
fee
ch
ara
ch
cte
ara
cte
19t
h
29t
Oct
h
ge
Fe
1
es
of
are
incl
n
Mo
Glo
bal
se-
ma
ins
en
ltipl
e
stri
ng
as
nts
an
pattern
ate
rep
gre
ed
yRE
mo
Re
pla
ce
nth non-passive group
in /
^(a
^(?
bc(
:ab
ma
c)
tch
ma
ed
tch
ma
ed
tch
ma
ed
tch
cte
ed
r
ol
Cla
ch
ara
White space
whi
te
\d
sp
Dig
it
Not
digi
\w
Wo
rd
Not
wo
de
cim
Oct
al
digi
PO
SI
[:u
X
pp
[:lo
er:]
we
[:al
r:]
ph
[:al
a:]
nu
[:di
m:]
git:
[:x
]
digi
[:p
t:]
un
[:bl
ct:]
an
k:]
pa
ce:
[:c
ntrl
[:gr
:]
ap
[:pr
h:]
int:
[:w
]
ord
:]
cas
e
r
cas
All
e
lett
ers
an
d
Dig
its
de
cim
al
nct
uat
e
an
ch
ara
ol
ch
d
ara
ch
ara
cte
rs
an
d

ild
(D
hy.
co
m/
ost
co
me
nta
tio
of
$.

by
Ap
solla
no
Yo
vel
urs
!ap
ollo
Groups and Ranges

Any character except new line (\n)

(alb) a or b

Group

(?:...) Passive (non-capturing) group

[abc] Range (a or b or c)

[^abc] Not (a or b or c)

[a-q] Lower case letter from a to q

[A-Q] Upper case letter from A to Q

[0-7] Digit from 0 to 7


be Group/subpattern number "x"

You might also like