Text

Regex Cheat Sheet

Comprehensive regular expression reference. Browse anchors, character classes, quantifiers, groups, lookarounds, flags, and common patterns. Filter by category or search.

52 results

PatternDescription
^Start of string (or line with m flag)
$End of string (or line with m flag)
\bWord boundary
\BNon-word boundary
\AStart of string (no multiline)
\ZEnd of string (no multiline)
.Any character except newline
\dDigit [0-9]
\DNon-digit [^0-9]
\wWord character [a-zA-Z0-9_]
\WNon-word character
\sWhitespace (space, tab, newline)
\SNon-whitespace
[abc]Character set — matches a, b, or c
[^abc]Negated set — not a, b, or c
[a-z]Range — any lowercase letter
[A-Z]Range — any uppercase letter
[0-9]Range — any digit
*Zero or more (greedy)
+One or more (greedy)
?Zero or one (optional)
{n}Exactly n times
{n,}n or more times
{n,m}Between n and m times
*?Zero or more (lazy/non-greedy)
+?One or more (lazy)
??Zero or one (lazy)
(abc)Capturing group
(?:abc)Non-capturing group
(?<name>abc)Named capturing group
a|bAlternation — matches a or b
(?=abc)Positive lookahead
(?!abc)Negative lookahead
(?<=abc)Positive lookbehind
(?<!abc)Negative lookbehind
\1Backreference to group 1
iCase insensitive match
gGlobal — find all matches
mMultiline — ^ and $ match line boundaries
sDotall — . matches newline too
uUnicode — treat pattern as Unicode
ySticky — match only from lastIndex
^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$Email address (simplified)
https?:\/\/[\w.-]+(?:\/\S*)?URL (http or https)
^\d{4}-\d{2}-\d{2}$Date in YYYY-MM-DD format
^\+?[1-9]\d{1,14}$Phone number (E.164 format)
^(?:\d{1,3}\.){3}\d{1,3}$IPv4 address (basic)
^[0-9a-fA-F]{6}$Hex color (without #)
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$Strong password (8+ chars, upper, lower, digit)
^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$UUID v4
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$Hex color with optional #
<([a-z][\w-]*)\b[^>]*>(.*?)<\/\1>HTML tag with content (captures tag)
Share

marduc812

2026