Regex Cheatsheet & Visualizer

Learn regex tokens fast, break a pattern into plain-language parts, and test it against your own text. Everything runs in your browser.

/
/
Paste a regular expression to see a plain-language breakdown.
Flags
Segments
Type a pattern above to see its parts.

Optional. Type or paste text and the matches are highlighted as you go.

Cheatsheet


. Any character except a line break Example: a.c
\d A digit (0-9) Example: \d+
\D Any character that is not a digit Example: \D+
\w A word character (a-z, A-Z, 0-9, _) Example: \w+
\W Any character that is not a word character Example: \W+
\s A whitespace character Example: \s+
\S Any character that is not whitespace Example: \S+
^ Start of the text Example: ^hello
$ End of the text Example: world$
\b A word boundary Example: \bword\b
\B A position that is not a word boundary Example: \Bword\B
[abc] Character set Example: [abc]+
[^abc] Negated set Example: [^abc]+
[a-z] Character set Example: [a-z0-9]+
(abc) Capture group Example: (abc)
(?:abc) Non-capturing group Example: (?:abc)+
(?<n>) Named group Example: (?<year>\d{4})
\1 Backreference Example: (\w)\1
a|b Alternation Example: cat|dog
? Optional (0 or 1) Example: colou?r
* Repeat 0 or more times Example: a*
+ Repeat 1 or more times Example: a+
{m,n} Repeat a given number of times Example: a{2,4}
+? The same, but as short as possible Example: <.+?>
(?=) Only if followed by Example: foo(?=bar)
(?!) Only if not followed by Example: foo(?!bar)
(?<=) Only if preceded by Example: (?<=\$)\d+
(?<!) Only if not preceded by Example: (?<!\$)\d+
\. Treat the next character as a literal Example: 3\.14
\n A line break Example: line\n
\t A tab Example: \tindented

Common validation patterns


Use casePatternDescriptionMatches
Email address^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$Validates the common shape of an email address.user@example.com
Phone number (US)^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$Matches 10-digit phone numbers with or without dashes, spaces or parentheses.123-456-7890
ZIP code (US)^\d{5}(-\d{4})?$Matches 5-digit and 9-digit ZIP codes.90210-1234
Date (YYYY-MM-DD)^\d{4}-\d{2}-\d{2}$Matches a simple numeric date format.2026-09-16
IP address (IPv4)^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$Matches the shape of an IPv4 address, without checking that each part is 0-255.192.168.1.1

These patterns check the shape of a value, not whether it exists. An address can match the email pattern perfectly and still bounce, so use them to catch typos early, never as the only validation.

What this tool provides


A compact reference of regular expression tokens, a breakdown that turns a pattern into plain sentences, and a tester that shows what the pattern matches in your own text.

When to use it


Use it while writing a pattern, while reading someone else’s pattern, or while teaching regex basics to a teammate. Reading a pattern out loud, piece by piece, is usually what makes it click.

Limitations


The breakdown follows JavaScript regular expressions, which is what your browser runs. Other flavors differ: PCRE, Python, Java and .NET each add syntax of their own, and POSIX tools such as grep and sed use an older, smaller syntax. The tester runs your pattern in a separate thread and stops it after a few seconds, so a pattern that backtracks forever cannot freeze the page.

How to use the cheatsheet


Search for a token, or paste a pattern and read it one part at a time.

  1. Browse or search the token list.
  2. Paste a pattern to see it split into segments.
  3. Type sample text to see what actually matches, then adjust the pattern.

FAQ


Does this tool upload my patterns?
No. The breakdown and the matching both run in your browser, and neither the pattern nor the text is sent anywhere.

Which regex flavor does it follow?
JavaScript, since that is the engine doing the work. Most of what is here — character classes, groups, quantifiers, anchors — is the same in every flavor.

Can I test my pattern here?
Yes. Type text in the test box and the matches are highlighted, with the captured groups listed for each one.

Why did my pattern get stopped?
Some patterns take exponential time on text that almost matches — a quantifier inside another quantifier, such as (a+)+b, is the usual cause. The tester gives up after a few seconds instead of freezing the page, and that timeout is itself a useful warning: the same pattern would stall a server.

Wikipedia — Regular expression
Wikipedia — PCRE
Wikipedia — Finite-state machine
Wikipedia — ReDoS
Wikipedia — Backtracking