ToolSnippet
🔣Developer Cheat Sheet

Regular Expression (RegEx) Syntax, Token & Lookahead Reference

A complete developer cheat sheet for RegEx tokens, character classes, anchors, lookaheads, lookbehinds, flags, and common production patterns with 1-click copy.

1-Click Syntax CopyProduction-Tested StandardsInteractive Tool Companion

Need to test or build regular expressions visually?

Use our interactive RegEx Token Builder with real-time match group highlighting.

Launch RegEx Token Builder & Tester

Character Classes & Shorthands

Predefined character classes for matching digits, word characters, and whitespace.

Syntax / TokenName / TypeDescriptionExample / Notes
\d
DigitMatches any digit from 0 to 93 in abc3
\D
Non-DigitMatches any character that is not a digita in 3a
\w
Word CharacterMatches alphanumeric characters and underscore [a-zA-Z0-9_]user_1
\W
Non-Word CharacterMatches any non-alphanumeric character! in hi!
\s
WhitespaceMatches space, tab, newline, form feed\n, \t, ' '
\S
Non-WhitespaceMatches any non-whitespace characterx in ' x '
.
Any CharacterMatches any character except newline (unless dotAll flag 's' is active)a, 1, @
[abc]
Character SetMatches any single character within bracketsa, b, or c
[^abc]
Negated SetMatches any character NOT listed within bracketsx in [^abc]
[a-z]
RangeMatches any lowercase letter between a and zf in [a-z]
[a-zA-Z0-9]
Alphanumeric RangeMatches standard alphanumeric charactersToken42

Quantifiers & Multipliers

Specify how many times a character or group should be repeated.

Syntax / TokenName / TypeDescriptionExample / Notes
*
Zero or MoreMatches 0 or more occurrences (greedy)ab* matches a, ab, abbb
+
One or MoreMatches 1 or more occurrences (greedy)ab+ matches ab, abbb
?
Zero or OneMatches 0 or 1 occurrence (optional)colou?r matches color, colour
{n}
Exactly N TimesMatches exactly n consecutive occurrences\d{4} matches 2026
{n,}
N or More TimesMatches at least n occurrences\d{2,} matches 12, 12345
{n,m}
Between N and M TimesMatches between n and m occurrences\w{3,8} matches user
*?
Lazy Zero or MoreMatches the smallest possible number of occurrences<.*?> for HTML tags
+?
Lazy One or MoreMatches the minimum necessary occurrences".+?" for quoted strings

Anchors & Word Boundaries

Assert positions in the string without consuming characters.

Syntax / TokenName / TypeDescriptionExample / Notes
^
Start of String / LineAsserts position at start of input (or line with multiline flag 'm')^Hello
$
End of String / LineAsserts position at end of input (or line with multiline flag 'm')World$
\b
Word BoundaryAsserts position between a word character (\w) and non-word character\bcat\b matches 'cat' not 'scatter'
\B
Non-Word BoundaryAsserts position where \b does not match\Bcat matches 'scatter'

Lookaheads & Lookbehinds (Zero-Width Assertions)

Match a pattern only if it is followed or preceded by another pattern.

Syntax / TokenName / TypeDescriptionExample / Notes
(?=...)
Positive LookaheadMatches if followed by pattern without including it in match\d+(?=px) matches 100 in 100px
(?!...)
Negative LookaheadMatches if NOT followed by pattern\d+(?!px) matches 100 in 100em
(?<=...)
Positive LookbehindMatches if preceded by pattern without including it in match(?<=\$)\d+ matches 50 in $50
(?<!...)
Negative LookbehindMatches if NOT preceded by pattern(?<!\$)\d+ matches 50 in €50

Common Production RegEx Patterns

Tested regular expressions ready for copy-pasting into backend and frontend code.

Syntax / TokenName / TypeDescriptionExample / Notes
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Email AddressStandard RFC 5322 compatible email validationuser@example.com
^https?:\/\/[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!$&'()*+,;=.]+$
HTTP / HTTPS URLValidates web URLs with query strings and pathshttps://toolsnippet.com
^(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
IPv4 AddressValidates 0-255 dotted decimal IP addresses192.168.1.1
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
Strong PasswordMin 8 chars, 1 uppercase, 1 lowercase, 1 number, 1 special charP@ssw0rd2026
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$
UUID v4Validates standard 36-character UUID string123e4567-e89b-12d3-a456-426614174000

Frequently Asked Questions

Common questions and developer tips regarding regular expression (regex) syntax & tokens.

Explore More Cheat Sheets

All Cheat Sheets →