DevToolbox

Free Online Regex Cheatsheet

Complete regex cheatsheet with interactive examples. Covers anchors, quantifiers, groups, character classes, lookaround, and common patterns — test directly in the browser.

100% Client-Side · Your data never leaves your browser
PatternDescription
^Start of string (or line with m flag)
$End of string (or line with m flag)
\bWord boundary
\BNon-word boundary
\AStart of string (no multiline)
\ZEnd of string (no multiline)
*Zero or more (greedy)
+One or more (greedy)
?Zero or one (optional)
{n}Exactly n repetitions
{n,}n or more repetitions
{n,m}Between n and m repetitions
*?Zero or more (lazy)
+?One or more (lazy)
(abc)Capturing group
(?:abc)Non-capturing group
(?<name>abc)Named capturing group
a|bAlternation (OR)
\1Backreference to group 1
\k<name>Named backreference
[abc]Character set — matches a, b, or c
[^abc]Negated set — matches anything but a, b, or c
[a-z]Character range — lowercase a to z
[a-zA-Z0-9]Alphanumeric characters
.Any character except newline (use s flag to include \n)
\dDigit [0-9]
\DNon-digit [^0-9]
\wWord character [a-zA-Z0-9_]
\WNon-word character
\sWhitespace (space, tab, newline)
\SNon-whitespace
\nNewline character
\tTab character
\rCarriage return
\0Null character
(?=...)Positive lookahead — followed by
(?!...)Negative lookahead — not followed by
(?<=...)Positive lookbehind — preceded by
(?<!...)Negative lookbehind — not preceded by
[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}Email address
https?:\/\/[^\s<>"]+[^\s<>",.]URL (http or https)
\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\bIPv4 address
\b\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])\bDate (YYYY-MM-DD)
(?:\+1[\s.-]?)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}US phone number
#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})\bHex color code
\b4[0-9]{12}(?:[0-9]{3})?\bVisa card number
[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}UUID v4
47 entries · Click any row to load pattern in the tester below

Mini Regex Tester

Open full tester
//

How to Use Regex Cheatsheet

The page is split into two sections: the cheatsheet table and a mini regex tester.

  • Use the search box to filter entries by pattern, description, or example text.
  • Use the category filter tabs to narrow down to Anchors, Quantifiers, Groups, Character Classes, Special Sequences, Lookaround, or Common Patterns.
  • Click any row in the table to load that pattern and its example text directly into the Mini Tester at the bottom.
  • In the Mini Tester, modify the pattern or test text as needed. Toggle flags (g, i, m, s) using the flag buttons. Click Test or press Ctrl/Cmd+Enter to run. Matches are highlighted inline and listed as code chips below.
  • For full match details including capturing groups and index positions, click Open full tester to go to the Regex Tester tool.

Keyboard shortcuts (when tester is focused): Ctrl/Cmd+Enter to test, Ctrl/Cmd+K to clear the tester.

Frequently Asked Questions

What regex flavor does this cheatsheet cover?

This cheatsheet covers JavaScript's ECMAScript regex syntax, which is also compatible with most other modern languages (Python, Java, Ruby, Go) for common patterns. JavaScript does not support some features like possessive quantifiers or atomic groups that are available in PCRE. The mini tester uses JavaScript's built-in RegExp engine.

What is the difference between greedy and lazy quantifiers?

Greedy quantifiers (*, +, {n,m}) match as much text as possible. Lazy quantifiers (*?, +?, {n,m}?) match as little as possible. For example, <.*> matches the entire string '<b>text</b>' greedily, while <.*?> matches only '<b>' lazily.

When should I use a non-capturing group (?:...) instead of ()?

Use (?:...) when you need to group alternatives or apply a quantifier to multiple tokens but do not need the captured text. Non-capturing groups are slightly faster and do not increment the group index, keeping your capture group numbering clean.

What is a lookahead and when is it useful?

A lookahead (?=...) asserts that what follows the current position matches a pattern, without consuming characters. For example, \d+(?= dollars) matches numbers followed by " dollars" but doesn't include " dollars" in the match. Negative lookahead (?!...) asserts the pattern does NOT follow.

Do JavaScript regex patterns support lookbehind assertions?

Yes, in modern browsers (Chrome 62+, Firefox 78+, Safari 16.4+). Lookbehind (?<=...) asserts what precedes the match. For example, (?<=\$)\d+ matches digits only when preceded by a dollar sign. Negative lookbehind is (?<!...). Avoid these in code targeting older browsers.

How do I test a regex directly on this page?

Click any row in the cheatsheet table to load that pattern into the Mini Regex Tester at the bottom of the page. You can then modify the pattern, toggle flags (g, i, m, s), and type or paste test text. Click Test or press Ctrl/Cmd+Enter to run. For a full-featured tester with match details and group extraction, click "Open full tester".

What common patterns are included in the cheatsheet?

The Common Patterns category includes production-ready patterns for email addresses, HTTP/HTTPS URLs, IPv4 addresses, ISO 8601 dates (YYYY-MM-DD), US phone numbers, hex color codes (#RGB / #RRGGBB), Visa card numbers, and UUID v4. Click any pattern to test it immediately.

Related Tools