Regex Cheatsheet Lookup

Searchable reference for 100+ regex tokens with live examples, common pattern library, inline tester, and cross-flavor notes for JS, Python, PCRE, POSIX.

Updated

Share:
Home/Developer Tools/Regex Cheatsheet Lookup

Regex Cheatsheet Lookup

Searchable reference for 100+ regex tokens with live examples, common pattern library, inline tester, and cross-flavor notes for JavaScript, Python, PCRE, and POSIX.

68 tokens
14 common patterns
4 flavors

Character Classes
13

Any digit (0-9).
\d+Order #12345 on 2024
\dabc 7 xyz
Any non-digit character.
\D+123abc456
Any word character (a-z, A-Z, 0-9, _).
\w+hello_world!
Any non-word character.
\Whi!
Any whitespace (space, tab, newline).
a\sba b
Any non-whitespace character.
\S+ hello
Any character except newline (unless s flag is set).
h.that hot hit
Character set — matches any one of a, b, or c.
[aeiou]hello
Negated character set — any char except a, b, or c.
[^aeiou]+hello
Character range — any lowercase letter.
[a-z]+ABC xyz 123
Any uppercase letter.
[A-Z]+Hello World
Any digit (same as \d in ASCII mode).
[0-9]{3}tel 555 ok
Any alphanumeric character.
[a-zA-Z0-9]+_abc123_

Anchors & Boundaries
7

Start of string (or line with m flag).
^HelloHello world
End of string (or line with m flag).
world$Hello world
Word boundary.
\bcat\bthe cat sat
Non-word boundary.
\Bcatconcatenate
Start of input (PCRE/Python — not JS).
\AHelloHello world
End of input (PCRE/Python — not JS).
world\ZHello world
Absolute end of string (PCRE).
end\zthe end

Quantifiers
11

Zero or more (greedy).
ab*a abbb
One or more (greedy).
ab+a abbb
Zero or one (optional).
colou?rcolor
Exactly n times.
\d{4}year 2024
n or more times.
\d{2,}1 22 333
Between n and m times.
\d{2,4}12345
Lazy zero or more — matches as few as possible.
<.*?><b>hi</b>
Lazy one or more.
\d+?12345
Lazy optional.
ab??ab
Lazy bounded quantifier.
\d{2,4}?12345
Possessive quantifier (PCRE) — no backtracking.
a*+baaab

Groups & Lookarounds
10

Capturing group.
(\d+)-(\d+)2024-04
Non-capturing group.
(?:ab)+ababab
Named capturing group.
(?<year>\d{4})year 2024
Backreference to group 1.
(\w)\1letter
Named backreference.
(?<q>["']).*?\k<q>"hi"
Positive lookahead — followed by abc.
\d+(?=px)10px 20em
Negative lookahead — not followed by abc.
\d+(?!px)10em 20px
Positive lookbehind — preceded by abc.
(?<=\$)\d+price $99
Negative lookbehind — not preceded by abc.
(?<!\$)\d+100 $99
Atomic group (PCRE) — no backtracking.
(?>a+)baaab

Alternation
2

Alternation — matches left OR right.
cat|dogI have a dog
Grouped alternation.
(red|green|blue)sky is blue

Escapes & Special Characters
9

Literal dot.
\.comsite.com
Literal forward slash (needed in /.../ syntax).
\/api/api/v1
Literal backslash.
\\npath\name
Newline character.
a\nba b
Tab character.
\t+a b
Carriage return.
\r\nline
Null character.
\0
Hex character (2 digits).
\x41A
Unicode character (4 hex digits).
\u00e9café

Flags / Modifiers
7

Global — find all matches.
/a/gbanana
Case-insensitive.
/hello/iHELLO
Multiline — ^ and $ match line starts/ends.
/^foo/mbar foo
Dotall — . matches newlines.
/a.b/sa b
Unicode mode — enables \p{} and proper unicode handling.
/\p{L}/ucafé
Sticky — matches only at lastIndex (JS).
/foo/yfoofoo
Extended — ignore whitespace & allow comments (PCRE/Python).
/ \d+ /xnum 42

Unicode Properties
9

Any Unicode letter (requires u flag in JS).
\p{Letter}+café123
Short form for Letter.
\p{L}
Any Unicode numeric character.
\p{Number}+abc123
Short form for Number.
\p{N}
Uppercase letter.
\p{Lu}+Hello
Lowercase letter.
\p{Ll}+Hello
Punctuation character.
\p{Punct}hi!
Characters from a specific script.
\p{Script=Greek}+hi Αθήνα
Negated — any non-letter.
\P{L}+abc 123

Frequently Asked Questions

What is the Regex Cheatsheet Lookup?

The Regex Cheatsheet Lookup is a free online tool that searchable reference for 100+ regex tokens with live examples, common pattern library, inline tester, and cross-flavor notes for js, python, pcre, posix.. It runs entirely in your browser with no installation or sign-up needed.

Which regex flavors are covered?

JavaScript (ECMAScript), Python (re/regex), PCRE (PHP/Perl), and POSIX (BRE/ERE). The Flavors tab highlights differences: \A/\Z anchors, possessive quantifiers, POSIX classes.

Does the inline tester run locally?

Yes. Every match and highlight is computed in your browser via native JavaScript RegExp. Nothing is sent to a server.

Can I copy patterns directly?

Yes — click Copy next to any token or common pattern (Email, URL, IPv4, UUID, strong password, etc.) to put the raw pattern on your clipboard.

Is the Regex Cheatsheet Lookup free to use?

Yes, the Regex Cheatsheet Lookup is 100% free with no registration, no hidden fees, and no usage limits. All processing happens locally in your browser, ensuring complete privacy.

Is my data safe with this tool?

Absolutely. The Regex Cheatsheet Lookup processes everything client-side in your browser. No data is uploaded to or stored on any server. Your content remains private on your device at all times.

Does the Regex Cheatsheet Lookup work on mobile devices?

Yes, the Regex Cheatsheet Lookup is fully responsive and works on smartphones and tablets. You can use it on any device with a modern web browser -- no app download required.

Do I need to create an account to use this tool?

No account or registration is needed. Simply open the Regex Cheatsheet Lookup in your browser and start using it immediately. There are no sign-up walls or usage restrictions.

What programming languages or formats does this support?

The Regex Cheatsheet Lookup supports a wide range of popular formats and languages. Check the tool interface for the full list of supported options.

How do I use the Regex Cheatsheet Lookup?

Simply enter your input in the provided field, adjust any settings to your preference, and the tool will process it instantly. You can then copy the result to your clipboard or download it.

What is the difference between greedy and lazy quantifiers in regex?

Greedy quantifiers like *, +, and {n,m} match as much text as possible, then backtrack only if the rest of the pattern fails. Lazy quantifiers, written by adding a ? (so *?, +?, ??, {n,m}?), match as little as possible and expand only when forced. The classic example is <.*> against "<b>hi</b>": the greedy version grabs the whole string from the first < to the last >, while the lazy <.*?> stops at the first >, matching just "<b>". Lazy quantifiers are essential for extracting individual tags, quoted strings, or delimited fields without overshooting. The cheatsheet's Quantifiers section lists every greedy and lazy form with worked examples, and you can drop a pattern straight into the inline tester to watch greedy versus lazy behavior on your own text before committing it to code.

What is the difference between lookahead and lookbehind in regex?

Both are zero-width assertions: they check whether text exists around a position without consuming it or including it in the match. Lookahead checks what follows. (?=abc) is positive (must be followed by abc) and (?!abc) is negative (must not be). So \d+(?=px) matches the digits in "10px" but leaves "px" out of the result. Lookbehind checks what precedes: (?<=abc) positive and (?<!abc) negative, so (?<=\$)\d+ grabs 99 from "$99" without capturing the dollar sign. JavaScript has supported lookbehind since ES2018, but some older engines and POSIX flavors lack it entirely. The Groups and Lookarounds section of the cheatsheet shows all four assertions with examples, and the live tester lets you confirm exactly which characters land inside the match versus the assertion.

Why does my regex match nothing or freeze on large input?

A regex that matches nothing usually has an unescaped special character, a wrong flag, or an anchor mismatch: ^ and $ only span lines when the m flag is set, and . skips newlines unless you add the s flag. A regex that freezes is almost always catastrophic backtracking, caused by nested quantifiers like (a+)+ or overlapping alternation that forces the engine to try an exponential number of paths on a non-matching string. Fixes include making quantifiers more specific, using atomic groups or possessive quantifiers in PCRE, or rewriting the pattern to avoid ambiguity. The inline tester here helps both cases: it shows the exact RegExp error message when a pattern is invalid, and it highlights every match so you can see immediately whether your pattern over-matches, misses edge cases, or returns nothing.

Why doesn't \d work in grep, sed, or awk?

Those tools use POSIX regular expressions, which do not define the shorthand classes \d, \w, or \s that you know from JavaScript, Python, or PCRE. In POSIX you use bracket expressions instead: [[:digit:]] for digits, [[:alpha:]] for letters, [[:alnum:]] for alphanumerics, and [[:space:]] for whitespace. POSIX also splits into two dialects: BRE (basic, used by grep and sed) requires backslashes before \(, \), \{, \?, and \+, while ERE (extended, used by grep -E and egrep) treats those as special by default. POSIX has no lookaround, no non-greedy quantifiers, and limited backreferences. The Flavors tab spells out exactly which features each engine supports, so before porting a pattern from your code into a shell command you can check whether the shorthand and assertions you rely on actually exist there.

How do I find all matches instead of just the first one?

By default a regex returns only the first match. To find every occurrence you add the global flag, g, to the pattern. Without g, JavaScript's exec and match return the single first hit; with g set, match returns an array of all matches and a loop with exec walks through each one. The g flag also tracks position via lastIndex, which is why repeatedly calling a global regex advances through the string. Pair g with i for case-insensitive matching across the whole input. In the inline tester, type g into the flags field and the match count updates to show every occurrence, with each one highlighted and listed by its character index; remove g and you will see it collapse back to just the first match. The Flags section explains g, i, m, s, u, and y with examples.

About the Regex Cheatsheet Lookup

The Regex Cheatsheet Lookup is a free, searchable reference for regular expressions, paired with a live tester so you can confirm a pattern matches before you paste it into code. Regex syntax is dense and easy to misremember — was it \d or [:digit:], does JavaScript support \A, is *? lazy or possessive? — and this tool puts the answer one search away. It is built for developers, data wranglers, and anyone who reaches for regex rarely enough to forget the details between uses.

Everything runs locally in your browser using the native JavaScript RegExp engine. Nothing you type into the tester is uploaded or stored, so you can paste log lines, sample records, or unreleased strings without them leaving your device. There is no sign-up, no usage cap, and nothing to install.

Four tabs, one reference

The tool is organized into four tabs:

  • Cheatsheet — dozens of regex tokens grouped into eight sections: character classes, anchors and boundaries, quantifiers, groups and lookarounds, alternation, escapes, flags, and Unicode properties. Each entry pairs a token with a plain-English description and a worked example showing the matched substring highlighted in real input.
  • Patterns — a library of 14 ready-to-use patterns for common validation jobs (email, HTTP/HTTPS URL, IPv4, IPv6, US and E.164 phone numbers, credit card, ISO date, hex color, strong password, US ZIP, URL slug, UUID v4, and username). Each comes with an explanation and sample strings.
  • Tester — a pattern field, a flags field, and a test string area that match in real time.
  • Flavors — side-by-side notes on how JavaScript, Python, PCRE, and POSIX differ.

Searching and copying tokens

Type into the search box on the Cheatsheet tab to filter every section at once — it matches against token names, descriptions, and the example patterns and inputs, so searching lookbehind, lazy, or \b all narrow the list instantly. Click any token to copy it to your clipboard, and use the Copy button beside any common pattern to grab the raw expression. The Test button on a pattern card loads it straight into the tester with a sample string, so you can see it run without retyping anything.

How the inline tester works

The tester compiles your pattern with the flags you supply and evaluates it against your test string as you type. It reports the total match count, highlights every match in the input, and lists each one with its character index — useful for spotting overlapping or empty matches, which appear marked as . With the global flag (g) set it finds all matches; without it, just the first. If the pattern is invalid, the exact RegExp error message is shown so you can fix the syntax rather than guess. Because it uses the browser's own engine, behavior mirrors what you get in Node.js and front-end code.

A few facts worth keeping straight, all covered in the Flavors tab:

  • The g flag returns every match, i is case-insensitive, m makes ^ and $ match line boundaries, s lets . match newlines, and u enables Unicode property escapes like \p{L}.
  • Lookbehind ((?<=...) and (?<!...)) has worked in JavaScript since ES2018.
  • \A, \Z, and \z anchors exist in PCRE and Python but not JavaScript — use ^ and $ instead.
  • POSIX flavors have no \d, \w, or \s; you use bracket classes such as [[:digit:]] and [[:alpha:]].

Why a tested reference matters

A wrong regex fails quietly. A pattern that looks right can over-match, miss edge cases, or trigger catastrophic backtracking that hangs on certain inputs. Checking it against real examples before shipping turns a guess into a verified expression. The Regex Cheatsheet Lookup keeps the syntax reference, a vetted starting library, and a live tester in one place — so you can look up a token, copy a known-good pattern, and prove it works in seconds.