RegEx Cheat Sheet
Common Tokens
Asingle character of: a, b, orc
A character except: a, b, orc
Acharacter in the range: a-z
Acchapter not in range: a-z
A character in the range: a-z or A-Z
Any single character
Any Whitespace character
Any non-whitespace character
Any digit
Any non-digit
Any word character
Any non-word character
Meta Sequence
‘Any Unicode sequences, line breaks included
Match one data unit
Unicode newlines
Vertical whitespace character
Negation of \v
Horizontal whitespace character
Negation of
Reset match
Match nth sub pattorn
Unicode propert X
Unicode property or script category
Negation of \pX
Negation of \p
Quote; treat as literals
Match sub pattem name?
Match sub pattern ‘name*
Match sub pattern name”
Match nth sub pattern
Match nth sub pattern
Recurse nth capture group
Recurses nth capture group
Match nth relative previous sub pattern
Recurse nth relative upcoming sub pattern
Match nth relative upcoming submitter
Recurse names capture group
Match previously-names capture group letter"
Recurses names capture group ‘letter’
Hex character YY
Hex characer YYYY
Octal character ddd
Control character Y
Backspace character
Makes any character literal
[abe] Capture enclosed
[abc] Match eithera orb
[a-z] Zero or one of a
[(*a-z] Zero of more of a
[a-zA-Z] One or more of a
Exactly 3 of a
\s 3ormore ofa
\s Between 3 and 6 ofa
\d Start of string
\D End of string
\w A word boundary
\W None-word boundary
General Tokens
Ms, Newline
AS Carriage return
7 Tab
wv Null character
Mn
i Character Class
M4 Modifiers
ex
ela Asingle character of: a,b, ore
Px Acharacter except: a, b, orc
PL Gr,
‘are character in the range: a-2
Ykename> Achapter not in range: a-2
Vename character in the range: a-2 or
\kinamed AZ
\gn Letters and digits
poi Letters
ign ASCIl codes 0-127
gem Space or tab only
\gstr> Control characters
\gen Decimal digits
peer Visible characters (not space)
arse Lowercase letters
Oy Uppercase letter
vernn Word characters
ddd
ey
Nb
\
(.)
(alb)
a(3}
a(3}
{3,6}
\n
\B
\n
\e
\t
\o
label]
[abc]
fa-z]
(az
[a-zA-Z1
{alum
{alpha
Iasciill
{blank
Ientridl
digit
{graph
Itlowerdl
Icupperd
Itword:l
(xdigita)
(cel
(elRegEx Cheat Sheet
Group Constants
Capture everything enclosed
(a
Match either a orb (alb)
Match everything enclosed .)
‘Atomic grouping (non-capturing) (>)
Duplicate sub pattern group number (2..)
‘Comment 028.)
Named Capturing Group (name’..)
Named Capturing Group (2sname>..)
lamed Capturing Group (2P...
Inline modifiers @imsxXU)
Conditional statements (2thyesino}
Recursive Conditional Statement —_((R#lyesino)
Conditional statement (AREnamelyesino}
Lookahead conditional (2(2=.,1yesino)
Lookbehind conditional (22=.yesino)
Recurse entire pattern CR)
Recurse first sub pattern om
Recurse first relative sub pattern (2)
Recurse subpattern ‘name (?&name)
Match subpattern ‘name* (2P=name)
Recurse subpattern ‘name* (2P>name)
Pre-define patterns before use (ADEFINE)..)
Positive Lookahead 2)
Negative Lookahead Old
Positive Lookbehind =.)
Negative Lookbehind Osh.)
Control verb ACCEPT)
Control verb FAIL)
Control verb (MARK:NAME)
Control verb COMMIT)
Control verb (PRUNE)
Control verb SKIP)
Control verb (THEN)
r CUTF)
r CUTE)
r CUTFI6)
r CUTF32
r cucr)
Line break modifier oR)
Line break modifier CLF)
Line break modifier ORLA)
Line break modifier CANYCRLF)
Line break modifier ANY)
Line break modifier R
Line break modifier (’BSR_ANYCRLF)
Line break modifier (‘BSR_UNICODE)
Regex engine m
(LIMIT_MATCH=x)
(LIMIT_RECURSION=d)
(NO_AUTO_POSSESS)
(NO_START_OPT)
Quantifiers
Zero or one of a
Zero of more of a
‘One or more of a
Exactly 3of a
3ormore of a
Between 3 and 6 of a
Greedy quantifier
Lazy quantifier
Possessive quantifier
Anchors
Start of match
Start of string
End of string
Start of string
End of string
Absolute end of string
Aword boundary
non-word boundary
Flags/Modifiers
Global
Multiline
Case sensitive
Ignore whitespace
Single line
Unicode
eXtended
Ungreedy
Anchor
Duplicate group names
Substitution
Complete match contents
Contents in capture group 1
Contents in capture group ‘foo
Hexidecimal replacement values
Tab
Carriage return
Newline
Form-feed
Uppercase Transformation
Lowercase transformation
Terminate any Transformation
a
at
(3)
af)
(3.6)
a?
att
\c
wv
Z
uv
\b
‘8
cpexeox-gea
\o
\or$t
Stfoo}
\x20, \XlO6Fab
\t
\
\n
¥
WU
ve
\E