Regex Cheat Sheet
Interactive regular expression reference with 60 patterns. Search, filter by category, copy any pattern, or click “Try it” to test in the Regex Tester.
Showing 60 of 60 patterns
Metacharacters
Pattern
Description
Example
Actions
Character Classes
Pattern
Description
Example
Actions
Quantifiers
Pattern
Description
Example
Actions
*? / +?Lazy quantifiers -- match as few characters as possible
<.*?> matches "<b>" in "<b>bold</b>"
*+ / ++Possessive quantifiers -- no backtracking (if supported)
a++b prevents backtracking on a's
Anchors & Boundaries
Pattern
Description
Example
Actions
\A / \ZAbsolute start / end of string (ignores multiline flag)
\Afoo matches only at very start of input
Groups & Lookaround
Pattern
Description
Example
Actions
(abc)Capturing group -- captures matched text for backreference
(\d+)-(\d+) captures "12" and "34"
(?<!abc)Negative lookbehind -- asserts what precedes does NOT match
(?<!\$)\d+ matches "50" in "50 items"
Flags
Pattern
Description
Example
Actions
Common Patterns
Pattern
Description
Example
Actions
\+?\d{1,3}[-.\s]?\(?\d{1,4}\)?[-.\s]?\d{1,4}[-.\s]?\d{1,9}Phone number (international)
+1 (555) 123-4567
[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}UUID v4 format
550e8400-e29b-41d4-a716-446655440000
(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}Strong password (8+ chars, upper, lower, digit, special)
P@ssw0rd!
Frequently Asked Questions
What are the most common regex metacharacters?
The most common regex metacharacters are: . (matches any character except newline), ^ (start of string), $ (end of string), * (zero or more), + (one or more), ? (zero or one), \ (escape character), | (alternation/OR), () (grouping and capturing), and [] (character class). These form the foundation of all regular expression patterns.
How do lookaheads and lookbehinds work in regex?
Lookaheads and lookbehinds are zero-width assertions that match a position without consuming characters. A positive lookahead (?=abc) matches if 'abc' follows the current position. A negative lookahead (?!abc) matches if 'abc' does NOT follow. A positive lookbehind (?<=abc) matches if 'abc' precedes the current position. A negative lookbehind (?<!abc) matches if 'abc' does NOT precede. They are powerful for matching patterns that depend on surrounding context without including that context in the match.
What's the difference between greedy and lazy quantifiers in regex?
Greedy quantifiers (*, +, {n,m}) match as many characters as possible while still allowing the overall pattern to match. Lazy quantifiers (*?, +?, {n,m}?) match as few characters as possible. For example, given the string '<b>bold</b>', the greedy pattern '<.*>' matches the entire string '<b>bold</b>', while the lazy pattern '<.*?>' matches just '<b>'. Use lazy quantifiers when you want the shortest possible match.
How do I test and debug regex patterns?
You can test regex patterns using DevBolt's free Regex Tester tool at devbolt.dev/tools/regex-tester. It provides real-time match highlighting, capture group inspection, and match details as you type. For generating patterns from plain English descriptions, try the Regex Generator at devbolt.dev/tools/regex-generator. Both tools run entirely in your browser with no signup required.