R
Test
Regex
Blog
Patterns
About
Quiz
Runtime: PCRE2 (Wasm)
Online
Save
Cheatsheet
A complete quick reference for regex tokens.
Lookup
All tokens
other
charclass
meta
groups
quantifiers
anchors
modifiers
subst
Newline
\n
Carriage return
\r
Tab
\t
Null character
\0
A single character of: a, b or c
[abc]
A character except: a, b or c
[^abc]
A character in the range: a-z
[a-z]
A character not in the range: a-z
[^a-z]
A character in the range: a-z or A-Z
[a-zA-Z]
Letters and digits
[[:alnum:]]
Letters
[[:alpha:]]
Ascii codes 0-127
[[:ascii:]]
Space or tab only
[[:blank:]]
Control characters
[[:cntrl:]]
Decimal digits
[[:digit:]]
Visible characters (not space)
[[:graph:]]
Lowercase letters
[[:lower:]]
Visible characters
[[:print:]]
Visible punctuation characters
[[:punct:]]
Whitespace
[[:space:]]
Uppercase letters
[[:upper:]]
Word characters
[[:word:]]
Hexadecimal digits
[[:xdigit:]]
Any single character
.
Any whitespace character
\s
Any non-whitespace character
\S
Any digit
\d
Any non-digit
\D
Any word character
\w
Any non-word character
\W
Any unicode sequences
\X
Match one data unit
\C
Unicode newlines
\R
Vertical whitespace character
\v
Negation of \v
\V
Horizontal whitespace character
\h
Negation of \h
\H
Reset match
\K
Match nth subpattern
\n
Unicode property X
\pX
Unicode property
\p{...}
Negation of \p
\PX
Negation of \p
\P{...}
Quote; treat as literals
\Q...\E
Match subpattern `name`
\k<name>
Match subpattern `name`
\k'name'
Match subpattern `name`
\k{name}
Match nth subpattern
\gn
Match nth subpattern
\g{n}
Match nth relative subpattern
\g{-n}
Recurse subpattern `name`
\g'name'
Recurse nth subpattern
\g<n>
Recurse nth subpattern
\g'n'
Recurse nth relative subpattern
\g<+n>
Recurse nth relative subpattern
\g'+n'
Hex character YY
\xYY
Hex character YYYY
\x{YYYY}
Octal character ddd
\ddd
Control character Y
\cY
Backspace character
[\b]
Makes any character literal
\
Capture everything enclosed
(...)
Match either a or b
(a|b)
Match everything enclosed
(?:...)
Atomic group
(?>...)
Duplicate subpattern group
(?|...)
Comment
(?#...)
Named capturing group
(?P<name>...)
Inline modifiers
(?imsxXU)
Conditional statement
(?(...)|)
Recurse entire pattern
(?R)
Recurse first subpattern
(?1)
Recurse first relative subpattern
(?+1)
Recurse subpattern `name`
(?&name)
Match subpattern `name`
(?P=name)
Recurse subpattern `name`
(?P>name)
Positive lookahead
(?=...)
Negative lookahead
(?!...)
Positive lookbehind
(?<=...)
Negative lookbehind
(?<!...)
Verbs
(*UTF16)
Zero or one of a
a?
Zero or more of a
a*
One or more of a
a+
Exactly 3 of a
a{3}
3 or more of a
a{3,}
Between 3 and 6 of a
a{3,6}
Greedy quantifier
a*
Lazy quantifier
a*?
Possessive quantifier
a*+
Start of match
\G
Start of string
^
End of string
$
Start of string
\A
End of string
\Z
Absolute end of string
\z
A word boundary
\b
Non-word boundary
\B
Global
g
Multiline
m
Case insensitive
i
Ignore whitespace
x
Single line
s
Unicode
u
eXtended
X
Ungreedy
U
Anchor
A
Complete match contents
\0
Contents in capture group 1
\1
Contents in capture group 1
$1
Contents in capture group `foo`
${foo}
Contents in capture group `foo`
\{foo}
Contents in capture group `foo`
\g<foo>
Contents in capture group 1
\g<1>
Hexadecimal replacement values
\x20
Hexadecimal replacement values
\x{06fa}
Tab
\t
Carriage return
\r
Newline
\n
Form-feed
\f