Skip to main content

Interactive Regex Cheatsheet — Try Every Token Live

Interactive regex cheat sheet — quick reference for every flavor (JS, Python, PCRE).

  • Runs locally
  • Category Developer & DevOps
  • Best for Formatting, validating, shrinking, or inspecting code-adjacent text.
Flavor:
\d

Any decimal digit (0-9). With /u flag in JS, also matches Unicode digits.

2 matches
order 42 items
\D

Anything that is NOT a digit.

8 matches
abc 123 def
\w

Word character: ASCII letter, digit, or underscore. NOT Unicode-aware by default in JS.

13 matches
hello_world 42!
\W

Anything NOT a word character.

3 matches
hi, world!
\s

Any whitespace: space, tab, newline, etc.

3 matches
one two	three
four
\S

Anything NOT whitespace.

3 matches
a b c
.

Any character except newline (use /s flag to include newline).

2 matches
a
b
[abc]

Any one of the listed characters (here: any vowel).

4 matches
regex is fun
[^abc]

Any character NOT in the list (negated class).

6 matches
regex is fun
[a-z]

Character range. Combine multiple ranges in one class: [a-zA-Z0-9].

4 matches
AB cd EF
\p{L}

Unicode property: any letter (any script). JS requires /u flag.

0 matches
abc αβγ 中文
\P{L}

Negated Unicode property: anything that is NOT a letter. JS requires /u.

0 matches
a1 中.x
\p{N}

Unicode property: any numeric character, including non-ASCII digits and numerals.

0 matches
a1 二 Ⅻ ½
\p{Lu}

Unicode property: any uppercase letter. Lowercase is \p{Ll}. JS requires /u.

0 matches
Hello WORLD abc
\p{Han}

Unicode script property: Han (CJK) characters. JS uses \p{Script=Han} with /u.

Not supported in JavaScript

0 matches
汉字 mixed カナ
\h

Horizontal whitespace (space, tab). PCRE/Perl; NOT in JS or Python re.

Not supported in JavaScript

0 matches
a	b  c
\v

In PCRE: any vertical whitespace (newline, CR, etc.). In JS: only the literal vertical tab \x0B.

Not supported in JavaScript

0 matches
line1
line2
[[:digit:]]

POSIX character class for digits inside a bracket class. PCRE/Python; NOT in JS.

Not supported in JavaScript

0 matches
abc123def
[[:alpha:]]

POSIX class for ASCII letters. Use inside [ ]. PCRE/Python only.

Not supported in JavaScript

0 matches
12 abc 34
\x41

Character by 2-digit hex code (\x41 = "A"). For >0xFF use \x{…} (PCRE) or \u{…} (JS /u).

1 matches
ABC abc
\u{1F600}

Unicode code point by hex. JS needs the /u flag; matches astral characters like emoji.

0 matches
😀 hi 😀
[\d-]

A literal hyphen in a class: place it first or last so it is not read as a range.

1 matches
call 555-0142 now
^

Start of string (or start of line with /m flag).

1 matches
foo bar foo
$

End of string (or end of line with /m flag).

1 matches
foo bar foo
\b

Word boundary: between \w and \W. ASCII-only in JS by default.

1 matches
a cat, the category, scattered cats
\B

NOT a word boundary.

2 matches
scattered concatenation
\A

Absolute start of string. NOT supported in JS — use ^.

Not supported in JavaScript

0 matches
foo bar
\Z

Absolute end of string. NOT supported in JS — use $.

Not supported in JavaScript

0 matches
foo bar foo
\z

Very end of string, ignoring any trailing newline (unlike \Z in Python). Python/PCRE only.

Not supported in JavaScript

0 matches
foo bar foo
\G

Anchor at the end of the previous match. PCRE/Perl; in JS use the sticky /y flag instead.

Not supported in JavaScript

0 matches
123 456
\K

Reset match start: everything before \K is matched but excluded from the result. PCRE only.

Not supported in JavaScript

0 matches
foobar foobaz
*

Zero or more of the preceding token. Greedy by default.

4 matches
g go goo gooo
+

One or more. Greedy by default.

3 matches
g go goo gooo
?

Zero or one. Useful for optional letters.

2 matches
color and colour
{n}

Exactly n times.

3 matches
years 2025 2026 1999
{n,m}

Between n and m times (inclusive).

4 matches
1 12 123 1234 12345
*?

Lazy zero-or-more: match as few as possible.

3 matches
<a><b><c>
++

Possessive: like + but never backtracks. PCRE only.

Not supported in JavaScript

0 matches
Invalid regular expression: /a++/g: Nothing to repeat
+?

Lazy one-or-more: match as few as possible while still matching.

1 matches
aXbYb
??

Lazy zero-or-one: prefer matching zero before trying one.

2 matches
ac abc
{n,}

At least n times, no upper limit.

2 matches
12 123 12345
{n,m}?

Lazy bounded repeat: match as few (down to n) as possible.

3 matches
123456
*+

Possessive zero-or-more: like * but never gives back. PCRE only.

Not supported in JavaScript

0 matches
Invalid regular expression: /"[^"]*+"/g: Nothing to repeat
?+

Possessive zero-or-one: matches one if present and never backtracks. PCRE only.

Not supported in JavaScript

0 matches
Invalid regular expression: /ab?+c/g: Nothing to repeat
{n}+

Possessive exact-count quantifier. PCRE only.

Not supported in JavaScript

0 matches
Invalid regular expression: /\d{2}+/g: Nothing to repeat
(abc)

Capturing group. Reference later as \1, \2, …

2 matches
alice@example bob@toolora
(?:abc)

Non-capturing group: groups for quantifying without capturing.

1 matches
abcdabab
(?<name>abc)

Named capturing group (JS/PCRE). Python uses (?P<name>abc).

2 matches
born 1989 died 2026
(?P<name>abc)

Python named group syntax. JS/PCRE use (?<name>abc) instead.

Not supported in JavaScript

(no live tester — concept-only entry)
\1

Backreference to the 1st captured group.

2 matches
the the cat sat sat
a|b

Alternation: match a OR b.

3 matches
cat dog fish bird
\k<name>

Backreference to a named group (JS/PCRE). Python uses (?P=name).

2 matches
say "hi" or 'yo'
(?P=name)

Python backreference to a named group. JS/PCRE use \k<name> instead.

Not supported in JavaScript

(no live tester — concept-only entry)
\g<1>

Subroutine call / numbered reference (Python re uses \g<1> in replacements; PCRE recursion uses (?1)).

Not supported in JavaScript

(no live tester — concept-only entry)
(?>…)

Atomic group: once matched, its contents never backtrack. PCRE/Perl; NOT in JS or Python re.

Not supported in JavaScript

0 matches
Invalid regular expression: /(?>a+)b/g: Invalid group
(?#…)

Inline comment: ignored by the engine. PCRE/Python; NOT in JS.

Not supported in JavaScript

0 matches
Invalid regular expression: /\d+(?# count)/g: Invalid group
(?i)

Inline flag: turn on case-insensitivity from this point. PCRE/Python; JS only allows (?i:…) scoped form.

Not supported in JavaScript

0 matches
Invalid regular expression: /(?i)cat/g: Invalid group
(?i:…)

Scoped inline flag: case-insensitive only inside the group. JS (v flag), PCRE, Python 3.11+.

0 matches
Invalid regular expression: /(?i:cat)Dog/g: Invalid group
(?1)

Recursion / subroutine call to group 1, enabling self-referential patterns. PCRE only.

Not supported in JavaScript

0 matches
Invalid regular expression: /(\w)(?1)?/g: Invalid group
(?=…)

Positive lookahead: assert what follows without consuming it.

2 matches
14px 20em 32px
(?!…)

Negative lookahead: assert what does NOT follow.

3 matches
14px 20em 32em
(?<=…)

Positive lookbehind: assert what precedes.

1 matches
pay $42 or 17 free
(?<!…)

Negative lookbehind: assert what does NOT precede.

2 matches
pay $42 or 17 free
(?=.*X)(?=.*Y)

Chained lookaheads: assert several independent conditions at once (a common password rule).

1 matches
a1 bad ok9
\b(?=\w)

Combine a boundary with a lookahead to pin a position without consuming characters.

0 matches
one ne e  two two wo o  three
(?<=\d)(?=(\d{3})+$)

Zero-width split point for inserting thousands separators (every 3 digits from the right).

0 matches
11234234344567
(?<=\w)(?=\W)

A custom word-end boundary built from two lookarounds: between a word char and a non-word char.

0 matches
hihii, bye, bye byebyeyee!
g

Global: find all matches instead of stopping at first.

(no live tester — concept-only entry)
i

Case-insensitive.

(no live tester — concept-only entry)
m

Multiline: ^ and $ match per line instead of whole string.

(no live tester — concept-only entry)
s

Dotall: "." matches newline too.

(no live tester — concept-only entry)
u

Unicode: enable \u{…}, \p{…}, full Unicode handling.

(no live tester — concept-only entry)
y

Sticky: match only starting at lastIndex. Useful for tokenizers.

(no live tester — concept-only entry)
d

JS hasIndices: each match exposes .indices with start/end offsets of every group.

(no live tester — concept-only entry)
v

JS unicodeSets (ES2024): upgrades /u with set operations [a&&b], [a--b], and \q{…} string literals.

(no live tester — concept-only entry)
x

Extended/verbose: ignore unescaped whitespace and allow # comments. PCRE/Python; NOT in JS.

Not supported in JavaScript

(no live tester — concept-only entry)
a

Python re.ASCII: make \w \d \s \b match ASCII only instead of full Unicode.

Not supported in JavaScript

(no live tester — concept-only entry)
U

PCRE ungreedy: swap greedy/lazy so quantifiers default to lazy. Not a standard JS or Python flag.

Not supported in JavaScript

(no live tester — concept-only entry)

What this tool does

Free interactive regex cheat sheet you can actually try. Every token, anchor, quantifier, group, and assertion has a live mini-tester next to it: type a test string and watch the match highlight in real time using your browser's native RegExp engine — no server round-trip, no noisy ads. Categories collapse so you can focus on what you need: Character classes (\d \w \s . [abc] [^abc] [a-z] \p{...}), Anchors (^ $ \b \B \A \Z), Quantifiers (* + ? {n,m} lazy vs greedy), Groups & References (() (?:) (?<name>) \1 \k<name>), Lookarounds ((?=) (?!) (?<=) (?<!)), and Flags (g i m s u y d). Flavor selector switches the reference between JavaScript, Python, and PCRE — the table calls out exactly which syntax each engine accepts (e.g. Python named groups are (?P<name>) but JS / PCRE use (?<name>); PCRE supports possessive quantifiers like a*+, neither JS nor Python do). Built for the moment you're three tabs deep on Stack Overflow trying to remember whether \b is a word boundary in Unicode mode — instead of reading, just type your case here and watch it match. 30+ real examples included so you can adapt rather than invent. 100% client-side; your patterns and test strings never leave the tab. Pair with our Regex Tester for full match / replace / capture group workflows, or with URL Encoder when escaping regex output for URLs.

Tool details

Input
Text + Structured content
The page exposes text boxes, numeric controls, file pickers, or structured inputs depending on the tool.
Output
Live result
The result area focuses on usable output, with copy, download, or preview actions when supported.
Privacy
Browser-side processing
The main tool logic does not call an external API, so inputs normally stay in the current tab.
Save / share
No account required
Open the page and use it; whether results survive refresh depends on the tool.
Performance budget
Initial JS <= 16 KB
No WASM budget is declared, keeping the tool quick to open on mobile.
Best fit
Developer & DevOps · Developer
Category and role tags drive related tools, internal links, and quick fit checks.

How to use

  1. 1. Input

    Paste or drop your content into the tool panel.

  2. 2. Process

    Click the button. All processing is local in your browser.

  3. 3. Copy / Download

    Copy the result or download to disk in one click.

How Regex Cheatsheet fits into your work

Use it in the small gaps between coding, reviewing, debugging, and shipping.

Developer jobs

  • Formatting, validating, shrinking, or inspecting code-adjacent text.
  • Preparing snippets for documentation, tickets, commits, or handoff.
  • Checking a small payload quickly without switching tools.

Developer checks

  • Run irreversible transforms like minify or obfuscate on a copy.
  • Keep secrets out of pasted snippets unless the tool explicitly stays local.
  • Use your normal tests or linter before shipping transformed code.

Good next steps

These links move the current task into a more complete workflow.

  1. 1 JSON Formatter & Validator Format, validate, and minify JSON instantly — right in your browser. Open
  2. 2 Regex Tester Test JavaScript regex live — match highlighting, group capture, replace preview, flag toggles — browser-only Open
  3. 3 Case Converter Convert text between camelCase, snake_case, kebab-case, PascalCase, Title Case, UPPER, lower — instant, browser-only Open

Real-world use cases

  • Verify whether \b respects Unicode before you ship the validator

    You wrote /\bword\b/ to highlight a term inside user comments, and QA files a bug that it fails on "café word". Open the Anchors section, type "café word" into the \b tester, then toggle the u flag in the Flags row. You see in three seconds that \b treats the é-to-space edge differently. Now you know to add the u flag instead of guessing across two more Stack Overflow tabs.

  • Settle a code-review fight over greedy vs lazy in one minute

    A teammate claims .*? in <(.+?)> is "always safer" for parsing tags. Open Quantifiers, paste "<a><b>" into both the .+ and .+? testers and watch greedy grab "a><b" while lazy stops at the first >. You drop the two screenshots into the PR thread and the thread closes. No need to spin up a sandbox repo or a Node REPL to prove a one-line point.

  • Port a Python pattern to JavaScript without a runtime surprise

    You inherit a Python scraper using (?P<id>\d+) and need it in a Node service. Switch the flavor selector to Python, confirm (?P<name>) is the named-group syntax, then flip to JavaScript and the table shows you JS wants (?<id>\d+) instead. You rewrite three named groups correctly the first time, instead of shipping a SyntaxError that only surfaces in CI 20 minutes later.

  • Teach a junior the lookahead trick on real input, not slides

    During onboarding a new hire asks why (?=.*\d) appears in your password rule. Open Lookarounds, type "abc1" into the (?=) tester and show the zero-width match that asserts "a digit exists somewhere" without consuming it. Then delete the 1 and watch it fail. Five minutes of live tokens beats a 30-slide deck, and they leave able to read the next assertion in your codebase on their own.

Common pitfalls

  • Assuming \d only matches 0-9: with the u flag on, /\d/u still only matches ASCII, but \p{Nd} matches Arabic-Indic digits too. Test both in the Character classes section before you trust either.

  • Copying a Python (?P<name>) group into JavaScript: JS throws a SyntaxError. Switch the flavor selector to confirm the engine wants (?<name>) instead, then test it live before pasting into your code.

  • Forgetting that ^ and $ match line boundaries only with the m flag: on "a\nb" without m, ^b never matches. Toggle the m flag in the Flags row on a two-line string to see the difference instantly.

Privacy

Every mini-tester compiles your pattern with the browser's native RegExp and runs entirely in the tab, so test strings and patterns never reach a server. The selected flavor and any pattern you choose to share are kept in the URL so a link reproduces your view; if your test string contains logs, internal IDs, or customer records, avoid pasting it into the shareable field and it stays purely local.

FAQ

Tool combos

Folks in your role tend to reach for these alongside this tool.

Made by Toolora · 100% client-side · Updated 2026-06-13