Back to Tools

Regex Interactive Cheat Sheet

High-performance regular expression reference guide for elite developers

PRO REFERENCE

Character Classes

. Any character (except \n)
\d Any digit (0-9)
\w Word char (a-z, 0-9, _)
\s Whitespace char
[a-z] Range (a to z)

Quantifiers

* 0 or more times
+ 1 or more times
? 0 or 1 (Optional)
{n} Exactly n times
{n,m} Between n and m

Anchors & Logic

^ Start of line
$ End of line
\b Word boundary
| OR (Alternation)
(?:...) Non-capturing group

Lookarounds

(?=...) Positive Lookahead
(?!...) Negative Lookahead
(?<=...) Positive Lookbehind
(? Negative Lookbehind

Pro Tip: Click to Copy

Click any regex token in the list above to instantly copy it to your clipboard for use in our advanced tester.

A compact regular expression reference you can copy from

Regular expressions are easy to forget between uses. Was the negative lookbehind written with a question mark and a less-than sign, or the other way around? This page is a short reference grouped into four cards, and every token is clickable so you can copy it instead of retyping it. It is meant to sit in a browser tab next to your editor or one of the other regex tools while you build a pattern.

How to use the sheet

  1. Scan the four cards: Character Classes, Quantifiers, Anchors & Logic and Lookarounds.
  2. Read the short description on the right of each row to confirm it does what you need.
  3. Click the red token itself. It is copied to your clipboard.
  4. Paste it into your pattern field in the Regex Tester, your code editor or wherever you are working.

What each card covers

Character Classes lists the dot (any character except a newline), the digit shorthand, the word-character shorthand, the whitespace shorthand and square-bracket ranges such as a to z. Quantifiers explains star, plus and question mark, plus the exact-count and range forms written with curly braces. Anchors & Logic covers the caret and dollar sign for line boundaries, the word boundary, the pipe for alternation, and the non-capturing group. Lookarounds shows positive and negative lookahead and lookbehind.

Situations where it helps

  • Writing a validation pattern and checking whether you need a word boundary or a line anchor.
  • Reviewing a colleague's pattern and decoding an unfamiliar token like a non-capturing group.
  • Learning regex for the first time and needing a short list rather than a full manual.
  • Building a find-and-replace for a log file and copying the lookahead syntax exactly.

Things to keep in mind

This is a deliberately short list of the most common building blocks, not a complete specification. It does not include escapes such as tab or newline, Unicode property classes, named groups, backreferences or lazy quantifiers, so consult your language's documentation for those. Regex engines also differ: lookbehind support and syntax vary between JavaScript, PCRE (used by PHP), Python and Java, and older engines may lack it entirely.

When the token is copied it goes to the clipboard only; the page shows no editor of its own. To try a pattern against sample text, paste it into the Regex Tester and run it there. Remember that when you place a pattern inside a string literal in code, backslashes usually need doubling, so the digit shorthand becomes two backslashes and a d in many languages.


Related Tools

Related Tools


Frequently Asked Questions

How do I copy a token from the cheat sheet?
Click the red token itself, for example the digit shorthand or the positive lookahead. It is copied to your clipboard so you can paste it into a pattern field or code editor. There is no separate copy button because the token is the button.
Which regex topics are included?
Four groups: character classes (dot, digit, word, whitespace, ranges), quantifiers (star, plus, optional, exact and range counts), anchors and logic (caret, dollar, word boundary, alternation, non-capturing group) and the four lookarounds.
Is this cheat sheet specific to one programming language?
It lists syntax common to most engines, and the companion tools on this site run on JavaScript. Details such as lookbehind availability differ between JavaScript, PCRE, Python and Java, so check your language's documentation for edge cases.
What is the difference between lookahead and lookbehind?
A lookahead checks what comes after the current position, while a lookbehind checks what comes before it. Both are zero-width, meaning they test a condition without consuming characters. Positive versions require a match, negative versions require the absence of one.
Where can I test a pattern after copying it?
Paste it into the Regex Tester on this site, enter some sample text, and run the analysis. The tester highlights matches, lists capture groups and can generate JavaScript, PHP, Python or Java code around your pattern.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.