100% Client-Side β’ 0 B Data Leaves Browser
web
Regular Expressions (Regex) Syntax & Patterns Cheat Sheet
Quick reference guide for Regular Expressions. Character classes, quantifiers, anchors, capture groups, lookarounds, and common developer patterns.
Character Classes & Quantifiers
Matches any single character except newline.
Matches any digit (0-9) / non-digit\d / \D
Matches word character (alphanumeric + underscore) / non-word character\w / \W
Matches whitespace (space, tab, newline) / non-whitespace\s / \S
Matches any character within specified character set[a-z0-9]
Negated character set: matches any character NOT in set[^a-z]
Match 0 or more / 1 or more / 0 or 1 occurrence* / + / ?
Match between n and m occurrences{n,m}
Anchors & Assertions
Start of string / end of string anchor^ / $
Word boundary / non-word boundary\b / \B
Positive lookahead: asserts abc follows(?=abc)
Negative lookahead: asserts abc does not follow(?!abc)
Positive lookbehind: asserts preceded by abc(?<=abc)
Negative lookbehind: asserts not preceded by abc(?<!abc)
Common Production Regex Patterns
Standard Email Address validator^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$
Web URL with optional HTTP/HTTPS scheme^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$
Strong password (minimum 8 chars, 1 letter, 1 number, 1 special)^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*#?&])[A-Za-z\d@$!%*#?&]{8,}$
Hex Color code (#fff or #4f46e5)^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$
ISO 8601 Date (YYYY-MM-DD)^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
Frequently Asked Questions
β’ What is the difference between greedy and lazy quantifiers in regex?
Greedy quantifiers (like `.*`) match as many characters as possible before stopping, while lazy quantifiers (like `.*?`) match as few characters as needed to satisfy the match condition.