Regex Tester
nothing you type leaves your browserCheat Sheet

Regex Cheat Sheet

Anchors

TokenDescription
^Start of string, or start of line with the m flag
$End of string, or end of line with the m flag
\bWord boundary
\BNot a word boundary

Quantifiers

TokenDescription
*Zero or more times
+One or more times
?Zero or one time
{n}Exactly n times
{n,}At least n times
{n,m}Between n and m times

Character Classes

TokenDescription
.Any character except line terminators
\dAny digit character (0-9)
\DAny non-digit character
\wAny word character (letter, digit, underscore)
\WAny non-word character
\sAny whitespace character
\SAny non-whitespace character
[abc]Any one of the characters a, b, or c
[^abc]Any character except a, b, or c
[a-z]Any character in the range a to z

Groups & Alternation

TokenDescription
(abc)Capturing group
(?:abc)Non-capturing group
(?<name>abc)Named capturing group
\1Backreference to capture group 1
|Alternation (OR)

Flags

TokenDescription
gGlobal — find all matches instead of stopping after the first
iCase-insensitive matching
mMultiline (JS) / Dotall (Ruby/Python) — ^ and $ match line boundaries or . matches newlines, depending on flavor
sDotall — . also matches newlines
uUnicode — enables full unicode matching
xExtended (Ruby/Python) — ignore whitespace and allow # comments in the pattern
ySticky — matches only from lastIndex