regex tester

/ /
·
no matches yet.
cheatsheet

anchors

^
start of string / line (m)
$
end of string / line (m)
\b
word boundary
\B
not a word boundary

character classes

.
any char (except \n unless s)
\d \D
digit / non-digit
\w \W
word char / non-word
\s \S
whitespace / non-whitespace
[abc]
any of a, b, c
[^abc]
none of a, b, c
[a-z]
range

quantifiers

*
0 or more (greedy)
+
1 or more
?
0 or 1
{n}
exactly n
{n,m}
n to m
*? +? ??
lazy variants

groups

(...)
capture group
(?:...)
non-capturing
(?<n>...)
named group
\1 \2
backreference
a|b
either a or b

lookarounds

(?=x)
positive lookahead
(?!x)
negative lookahead
(?<=x)
positive lookbehind
(?<!x)
negative lookbehind

escapes

\.
literal dot
\\
literal backslash
\n \t \r
newline / tab / return
￿
unicode code point
\p{L}
unicode property (u flag)
copied