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.
\dAny decimal digit (0-9). With /u flag in JS, also matches Unicode digits.
order 42 items
\DAnything that is NOT a digit.
abc 123 def\wWord character: ASCII letter, digit, or underscore. NOT Unicode-aware by default in JS.
hello_world 42!
\WAnything NOT a word character.
hi, world!
\sAny whitespace: space, tab, newline, etc.
one two three four
\SAnything NOT whitespace.
a b c
.Any character except newline (use /s flag to include newline).
a
b[abc]Any one of the listed characters (here: any vowel).
regex is fun
[^abc]Any character NOT in the list (negated class).
regex is fun
[a-z]Character range. Combine multiple ranges in one class: [a-zA-Z0-9].
AB cd EF\p{L}Unicode property: any letter (any script). JS requires /u flag.
abc αβγ 中文\P{L}Negated Unicode property: anything that is NOT a letter. JS requires /u.
a1 中.x\p{N}Unicode property: any numeric character, including non-ASCII digits and numerals.
a1 二 Ⅻ ½\p{Lu}Unicode property: any uppercase letter. Lowercase is \p{Ll}. JS requires /u.
Hello WORLD abc\p{Han}Unicode script property: Han (CJK) characters. JS uses \p{Script=Han} with /u.
⚠ Not supported in JavaScript
汉字 mixed カナ\hHorizontal whitespace (space, tab). PCRE/Perl; NOT in JS or Python re.
⚠ Not supported in JavaScript
a b c\vIn PCRE: any vertical whitespace (newline, CR, etc.). In JS: only the literal vertical tab \x0B.
⚠ Not supported in JavaScript
line1
line2[[:digit:]]POSIX character class for digits inside a bracket class. PCRE/Python; NOT in JS.
⚠ Not supported in JavaScript
abc123def[[:alpha:]]POSIX class for ASCII letters. Use inside [ ]. PCRE/Python only.
⚠ Not supported in JavaScript
12 abc 34\x41Character by 2-digit hex code (\x41 = "A"). For >0xFF use \x{…} (PCRE) or \u{…} (JS /u).
ABC abc\u{1F600}Unicode code point by hex. JS needs the /u flag; matches astral characters like emoji.
😀 hi 😀[\d-]A literal hyphen in a class: place it first or last so it is not read as a range.
call 555-0142 now
^Start of string (or start of line with /m flag).
foo bar foo$End of string (or end of line with /m flag).
foo bar foo\bWord boundary: between \w and \W. ASCII-only in JS by default.
a cat, the category, scattered cats
\BNOT a word boundary.
scattered concatenation
\AAbsolute start of string. NOT supported in JS — use ^.
⚠ Not supported in JavaScript
foo bar\ZAbsolute end of string. NOT supported in JS — use $.
⚠ Not supported in JavaScript
foo bar foo\zVery end of string, ignoring any trailing newline (unlike \Z in Python). Python/PCRE only.
⚠ Not supported in JavaScript
foo bar foo\GAnchor at the end of the previous match. PCRE/Perl; in JS use the sticky /y flag instead.
⚠ Not supported in JavaScript
123 456\KReset match start: everything before \K is matched but excluded from the result. PCRE only.
⚠ Not supported in JavaScript
foobar foobaz*Zero or more of the preceding token. Greedy by default.
g go goo gooo
+One or more. Greedy by default.
g go goo gooo
?Zero or one. Useful for optional letters.
color and colour{n}Exactly n times.
years 2025 2026 1999
{n,m}Between n and m times (inclusive).
1 12 123 1234 12345
*?Lazy zero-or-more: match as few as possible.
<a><b><c>
++Possessive: like + but never backtracks. PCRE only.
⚠ Not supported in JavaScript
⚠ Invalid regular expression: /a++/g: Nothing to repeat+?Lazy one-or-more: match as few as possible while still matching.
aXbYb??Lazy zero-or-one: prefer matching zero before trying one.
ac abc{n,}At least n times, no upper limit.
12 123 12345
{n,m}?Lazy bounded repeat: match as few (down to n) as possible.
123456
*+Possessive zero-or-more: like * but never gives back. PCRE only.
⚠ Not supported in JavaScript
⚠ Invalid regular expression: /"[^"]*+"/g: Nothing to repeat?+Possessive zero-or-one: matches one if present and never backtracks. PCRE only.
⚠ Not supported in JavaScript
⚠ Invalid regular expression: /ab?+c/g: Nothing to repeat{n}+Possessive exact-count quantifier. PCRE only.
⚠ Not supported in JavaScript
⚠ Invalid regular expression: /\d{2}+/g: Nothing to repeat(abc)Capturing group. Reference later as \1, \2, …
alice@example bob@toolora(?:abc)Non-capturing group: groups for quantifying without capturing.
abcdabab
(?<name>abc)Named capturing group (JS/PCRE). Python uses (?P<name>abc).
born 1989 died 2026
(?P<name>abc)Python named group syntax. JS/PCRE use (?<name>abc) instead.
⚠ Not supported in JavaScript
\1Backreference to the 1st captured group.
the the cat sat sata|bAlternation: match a OR b.
cat dog fish bird
\k<name>Backreference to a named group (JS/PCRE). Python uses (?P=name).
say "hi" or 'yo'
(?P=name)Python backreference to a named group. JS/PCRE use \k<name> instead.
⚠ Not supported in JavaScript
\g<1>Subroutine call / numbered reference (Python re uses \g<1> in replacements; PCRE recursion uses (?1)).
⚠ Not supported in JavaScript
(?>…)Atomic group: once matched, its contents never backtrack. PCRE/Perl; NOT in JS or Python re.
⚠ Not supported in JavaScript
⚠ Invalid regular expression: /(?>a+)b/g: Invalid group(?#…)Inline comment: ignored by the engine. PCRE/Python; NOT in JS.
⚠ Not supported in JavaScript
⚠ 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
⚠ 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+.
⚠ 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
⚠ Invalid regular expression: /(\w)(?1)?/g: Invalid group(?=…)Positive lookahead: assert what follows without consuming it.
14px 20em 32px
(?!…)Negative lookahead: assert what does NOT follow.
14px 20em 32em
(?<=…)Positive lookbehind: assert what precedes.
pay $42 or 17 free
(?<!…)Negative lookbehind: assert what does NOT precede.
pay $42 or 17 free
(?=.*X)(?=.*Y)Chained lookaheads: assert several independent conditions at once (a common password rule).
a1 bad ok9
\b(?=\w)Combine a boundary with a lookahead to pin a position without consuming characters.
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).
11234234344567
(?<=\w)(?=\W)A custom word-end boundary built from two lookarounds: between a word char and a non-word char.
hihii, bye, bye byebyeyee!
gGlobal: find all matches instead of stopping at first.
iCase-insensitive.
mMultiline: ^ and $ match per line instead of whole string.
sDotall: "." matches newline too.
uUnicode: enable \u{…}, \p{…}, full Unicode handling.
ySticky: match only starting at lastIndex. Useful for tokenizers.
dJS hasIndices: each match exposes .indices with start/end offsets of every group.
vJS unicodeSets (ES2024): upgrades /u with set operations [a&&b], [a--b], and \q{…} string literals.
xExtended/verbose: ignore unescaped whitespace and allow # comments. PCRE/Python; NOT in JS.
⚠ Not supported in JavaScript
aPython re.ASCII: make \w \d \s \b match ASCII only instead of full Unicode.
⚠ Not supported in JavaScript
UPCRE ungreedy: swap greedy/lazy so quantifiers default to lazy. Not a standard JS or Python flag.
⚠ Not supported in JavaScript
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. Input
Paste or drop your content into the tool panel.
-
2. Process
Click the button. All processing is local in your browser.
-
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 JSON Formatter & Validator Format, validate, and minify JSON instantly — right in your browser. Open
- 2 Regex Tester Test JavaScript regex live — match highlighting, group capture, replace preview, flag toggles — browser-only Open
- 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.
- 555 Timer Calculator Astable f = 1.44/((R1+2R2)C) + monostable t = 1.1RC — pick R1, R2, C in Ω/kΩ and µF/nF, read frequency, duty cycle and pulse width — browser-only
- Add Line Numbers Number every line of pasted text — set start, step and separator, zero-pad to align, skip blanks, or strip numbers back off — browser-only
- AES Text Encryptor Encrypt & decrypt text with a password — AES-256-GCM + PBKDF2 via WebCrypto — 100% in your browser, nothing uploaded
- Affine Cipher Encoder & Decoder Encrypt and decrypt the ax+b affine cipher with live modular-inverse check, browser-only