Regular Expression Cheatsheet
A searchable cheatsheet for regular expressions. Browse by group or search by token or meaning to find anchors, character classes, quantifiers, groups, lookarounds and flags, each with a short example.
How to use the regex cheatsheet
- Search for a token like \d or a word like digit or anchor.
- Read the meaning and the short example for each match.
- Copy the token straight into your pattern.
Examples
Match any digit
\d
Any digit, equivalent to [0-9]
Positive lookahead
(?=...)
Assert what follows without consuming it
Frequently asked questions
What does \d mean in regex?
\d matches any single digit and is equivalent to the character class [0-9]. Its opposite, \D, matches any non-digit.
What is the difference between * and +?
The star matches zero or more of the preceding token, so it can match nothing. The plus matches one or more, so it requires at least one occurrence.
What is a lookahead?
A lookahead like (?=...) asserts that some pattern follows the current position without including it in the match. (?!...) asserts that a pattern does not follow.
What do regex flags like g, i and m do?
The g flag finds all matches, i makes matching case-insensitive, and m lets the anchors ^ and $ match at line breaks rather than only the whole string.
How do I match a literal special character?
Escape it with a backslash. For example, \. matches a literal dot and \\ matches a literal backslash.
Related tools
Regex Tester
Test a regular expression against text with live match highlighting, capture groups and flags. See every match and replace text. Runs in your browser.
Regex Explainer
Paste a regular expression to get a plain-English, token-by-token breakdown of what every part does, plus a summary and flag guide. Runs in your browser.
Regex Pattern Builder
Build ready-to-use regex for email, URL, IPv4, UUID, dates and more, or compose password rules with checkboxes. Copy the pattern. Runs in your browser.
.env to JSON
Convert a .env file to JSON, or JSON back to .env. Parses KEY=value lines, comments, quotes and export. Runs entirely in your browser.
ASCII Table
Full ASCII table for all 128 codes with decimal, hex, octal and binary values, character names and descriptions. Search by code, hex or character.
Aspect Ratio Box Generator
Generate CSS for a responsive aspect-ratio container. Use the modern aspect-ratio property or the padding-top fallback, then copy the ready code.