Regex Cheat Sheet — Interactive Regular Expression Syntax Reference, Python & JavaScript Examples, Live Tester

Regex Cheat Sheet

Regex cheat sheet & live tester

Interactive regular expression cheat sheet with examples — test patterns like regex101, plus Python, JavaScript, Java, Perl, and more.

2 matches
Emails: alice@example.com and bob@asli.dev — not-an-email.
#IndexMatchGroups
18alice@example.com
230bob@asli.dev

Common regex recipes

Click a recipe to load it into the tester — regex cheat sheet with examples for everyday patterns.

Regex syntax cheat sheet

Anchors

TokenMeaningExample
Start of string (or line with m flag)^Hello
End of string (or line with m flag)world$
Start of string only (Python/Perl/.NET; not JS)
End of string (before final newline in some flavors)
Word boundary\bcat\b
Not a word boundary\Bcat

Quantifiers

TokenMeaningExample
0 or more (greedy)a*
1 or more (greedy)a+
0 or 1 (greedy)colou?r
Exactly n times\d{3}
n or more times\d{2,}
Between n and m times\d{2,4}
0 or more (lazy)<.*?>
1 or more (lazy)a+?
0 or 1 (lazy)
Possessive + (Java/PCRE; not JS)

Character classes

TokenMeaningExample
Any char except newline (unless s/dotall)a.c
Digit [0-9]\d+
Non-digit\D+
Word char [A-Za-z0-9_]\w+
Non-word char\W+
Whitespace\s+
Non-whitespace\S+
One of a, b, or c[aeiou]
Not a, b, or c[^0-9]
Range a to z[A-Za-z]
Any character including newline (JS trick)

Groups & references

TokenMeaningExample
Capturing group(\d{3})
Non-capturing group(?:https?)
Named capture (JS/Python/.NET/Java)(?<year>\d{4})
Backreference to group 1(\w+)\s+\1
Named backreference
Alternation (OR)cat|dog

Lookahead & lookbehind

TokenMeaningExample
Positive lookahead\d+(?=px)
Negative lookaheadfoo(?!bar)
Positive lookbehind(?<=\$)\d+
Negative lookbehind(?<!@)\b\w+

Flags / modifiers

TokenMeaningExample
Global — find all matches (JS)
Case-insensitive/hello/i
Multiline — ^/$ match line ends
Dotall — . matches newline (JS/Python re.S)
Unicode mode (JS)
Sticky — match from lastIndex (JS)
Python flag constants
Inline flags (many flavors)

Escapes & special

TokenMeaningExample
Literal backslash
Tab, newline, carriage return
Hex character\x41 → A
Unicode code point (JS)\u00A9
Unicode property letter (with u)
Quote literal span (Java/Perl)

Language flavors

Python regex cheat sheet, JavaScript / JS, Java, Perl, C# /.NET, bash, R, SQL, PowerShell, and editor notes.

JavaScript regex cheat sheet essentials for browser and Node.

  • Use /pattern/flags or new RegExp(pattern, flags).
  • Remember lastIndex with the g flag when reusing a RegExp.
  • Named groups: /(?<year>\d{4})/u — access match.groups.year.
const re = /\b\w+@\w+\.\w+/gi;
const text = "a@b.com and c@d.org";
console.log([...text.matchAll(re)]);

Regex Cheat Sheet — Syntax, Examples & Tester

Free interactive regex cheat sheet with a live tester. Includes a Python regex cheat sheet, JavaScript / JS regex cheat sheet, Java, Perl, C#, bash/grep, and R notes — a practical regular expression cheat sheet with examples.

Regex cheat sheet
Python regex cheat sheet
Regex cheat sheet Python
Regex Python cheat sheet
Java regex cheat sheet
Perl regex cheat sheet
JavaScript regex cheat sheet
JS regex cheat sheet
Regex cheat sheet JS
Regex syntax cheat sheet
Regex cheat sheet with examples
Regex cheat sheet PDF
Printable regex cheat sheet
Bash regex cheat sheet
Grep regex cheat sheet
PowerShell regex cheat sheet
R regex cheat sheet
SQL regex cheat sheet
PCRE regex cheat sheet
Regex 101 cheat sheet
VS Code regex cheat sheet
Pandas regex cheat sheet
C# regex cheat sheet
PHP regex cheat sheet

Frequently asked questions

What is a regex cheat sheet?
A regex cheat sheet (regular expression cheat sheet) is a quick reference for syntax tokens like ^, $, \d, quantifiers, groups, and lookarounds — often paired with a live tester and language-specific notes for Python, JavaScript, Java, and more.
Is this a Python regex cheat sheet too?
Yes. Besides the general regex syntax cheat sheet, this page includes Python re module tips and examples (raw strings, flags, search/findall/sub), plus JavaScript, Java, Perl, C#/.NET, bash/grep, and R notes.
How do I test a regex pattern with examples?
Use the live tester: enter a pattern and flags, paste a test string, and see highlighted matches, indexes, and capture groups — similar to regex101-style debugging on a printable online cheat sheet.
Do Java and JavaScript regex work the same?
Most core tokens are shared, but flavors differ: Java strings need double escaping, possessive quantifiers exist in Java/PCRE, and JS has g/y/u flag behavior. Use the language tabs for flavor-specific cheat sheet notes.
Can I use this as a printable regex cheat sheet?
Yes — open the page and print (Ctrl/Cmd+P) for a printable regex cheat sheet PDF via your browser’s print-to-PDF. The syntax tables and recipes print cleanly.

Looking for a python regex cheat sheet with examples, javascript regex cheat sheet, Linux/bash/grep notes, or a printable regex cheat sheet PDF? Use the tester and tables above, then print to PDF. Covers anchors, quantifiers, character classes, groups, lookarounds, and common recipes — a complete regex expression cheat sheet for daily coding.