Regular Expressions Cheatsheet — Regex Syntax Reference

Complete regex reference: character classes, quantifiers, anchors, groups, lookahead, common patterns for emails, URLs.

Character Classes

PatternMatches
.Any character (except newline)
\dDigit [0-9]
\DNon-digit
\wWord character [a-zA-Z0-9_]
\WNon-word character
\sWhitespace
\SNon-whitespace
[abc]a, b, or c
[^abc]NOT a, b, or c
[a-z]Lowercase letter

Quantifiers

PatternMeaning
*0 or more
+1 or more
?0 or 1
{3}Exactly 3
{2,5}Between 2 and 5
{3,}3 or more
*?0 or more (lazy)
+?1 or more (lazy)

Anchors & Boundaries

PatternMatches
^Start of string/line
$End of string/line
\bWord boundary

Groups & Lookaround

(abc)          # Capture group
(?:abc)        # Non-capturing group
(?<name>abc)   # Named group
\1             # Backreference to group 1
a|b            # a OR b
(?=abc)        # Lookahead (followed by abc)
(?!abc)        # Negative lookahead
(?<=abc)       # Lookbehind (preceded by abc)
(?<!abc)       # Negative lookbehind

Flags

FlagMeaning
gGlobal (all matches)
iCase insensitive
mMultiline (^ and $ per line)
sDotall (. matches newline)

Need These Tools as an API?

TextForge API offers 20+ developer toolkit endpoints. Free tier: 50 requests/day.

Try TextForge API Free →

Related Tools