Regex Cheatsheet
Quick reference guide for regular expressions with interactive match highlighting
All processing happens in your browser. No data is uploaded.
Regex Cheatsheet
Quick reference guide for regular expressions with interactive match highlighting
🔒All processing happens in your browser. No data is uploaded.
Search patterns, descriptions...
All
Character Classes
Quantifiers
Anchors
Groups
Assertions
Flags
Character Classes
10
.Any character except newline
h.t\dDigit (0-9)
\d{3}\DNon-digit
\D+\wWord character (a-z, A-Z, 0-9, _)
\w+\WNon-word character
\W\sWhitespace (space, tab, newline)
\s+\SNon-whitespace character
\S+[abc]Any character in the set
[aeiou][^abc]Any character NOT in the set
[^aeiou][a-z]Any character in the range
[a-f]Quantifiers
8
*Zero or more
go*d+One or more
go+d?Zero or one (optional)
colou?r{n}Exactly n times
\d{4}{n,}n or more times
\d{2,}{n,m}Between n and m times
\d{2,4}*?Zero or more (lazy)
<.*?>+?One or more (lazy)
\w+?Anchors
4
^Start of string (or line in multiline)
^Hello$End of string (or line in multiline)
world$\bWord boundary
\bcat\b\BNon-word boundary
\BcatGroups
5
(abc)Capturing group
(ha)+(?:abc)Non-capturing group
(?:ha)+(?<name>abc)Named capturing group
(?<year>\d{4})\1Backreference to group 1
(\w+)\s\1(a|b)Alternation (a or b)
(cat|dog)Assertions
4
(?=abc)Positive lookahead
\w+(?=\s)(?!abc)Negative lookahead
\d+(?!\$)(?<=abc)Positive lookbehind
(?<=\$)\d+(?<!abc)Negative lookbehind
(?<!\$)\d+Flags
6
gGlobal - find all matches
/cat/giCase-insensitive matching
/hello/imMultiline - ^ and $ match line boundaries
/^foo/msDotall - dot matches newline too
/a.b/suUnicode - enable full Unicode support
/\p{L}/uySticky - match from lastIndex only
/\d+/y