REGEX CHEAT SHEET / CLICK TO TRY

Regex Cheat Sheet

Click any syntax to try it on real text.

Runs locally · text is not uploaded
Match Details

Explanation

Common patterns

Code

Cheat sheet (click to insert)

characters

  • Any character except newline
  • Number
  • Word character
  • Whitespace
  • Not a digit
  • Not a word character
  • Not whitespace
  • a, b or c
  • Not a, b or c
  • a to z
  • Any letter (needs u)
  • Chinese characters

Location

  • Start
  • End
  • Word boundary
  • Not a word boundary

Quantity

  • 0 or more
  • 1 or more
  • 0 or 1
  • Exactly 3
  • 2 or more
  • 2 to 5
  • Lazy: as few as possible

Groups and references

  • Capture Group
  • Non-capturing group
  • Named capture group
  • Back-reference to group 1
  • Back-reference by name
  • a or b

Lookarounds

  • Followed by abc
  • Not followed by abc
  • Preceded by abc
  • Not preceded by abc

Escapes

  • A literal dot
  • A literal slash
  • Newline
  • Tab
  • Unicode character

Replacement syntax

  • $1 $2Groups 1 and 2
  • $<name>Named group
  • $&The whole match
  • $`Text before the match
  • $'Text after the match
  • $$A literal $

YOUR NEXT STEP

Connect useful tools with your company workflow

Create a company account to configure website monitoring, business email and notifications, and invite your team to work together.

New companies receive a 14-day Pro trial, with no card required. Trials exclude the paid monthly credit grant.

Already have an account? Open your workspace →

Regex syntax at a glance

characters

  • .Any character except newline
  • \dNumber
  • \wWord character
  • \sWhitespace
  • \DNot a digit
  • \WNot a word character
  • \SNot whitespace
  • [abc]a, b or c
  • [^abc]Not a, b or c
  • [a-z]a to z
  • \p{L}Any letter (needs u)
  • [\u4e00-\u9fff]Chinese characters

Location

  • ^Start
  • $End
  • \bWord boundary
  • \BNot a word boundary

Quantity

  • *0 or more
  • +1 or more
  • ?0 or 1
  • {3}Exactly 3
  • {2,}2 or more
  • {2,5}2 to 5
  • *?Lazy: as few as possible

Groups and references

  • (abc)Capture Group
  • (?:abc)Non-capturing group
  • (?<name>abc)Named capture group
  • \1Back-reference to group 1
  • \k<name>Back-reference by name
  • a|ba or b

Lookarounds

  • (?=abc)Followed by abc
  • (?!abc)Not followed by abc
  • (?<=abc)Preceded by abc
  • (?<!abc)Not preceded by abc

Escapes

  • \.A literal dot
  • \/A literal slash
  • \nNewline
  • \tTab
  • \u00A9Unicode character

Replacement syntax

  • $1 $2Groups 1 and 2
  • $<name>Named group
  • $&The whole match
  • $`Text before the match
  • $'Text after the match
  • $$A literal $

How to use it

  1. Type the pattern and switch on the flags you need (usually g and i).
  2. Paste text; matches highlight live and the table lists each position and group.
  3. Switch to Replace to rewrite text or Extract list to collect matches, then copy the code for your language.

Frequently asked questions

Greedy vs lazy?

By default * + {n,} are greedy and take as much as possible; adding ? makes them lazy. In the text x1y x2y, x.*y matches everything while x.*?y stops at the first y.

Which regex flavour is this?

Your browser's JavaScript (ECMAScript 2024) syntax, with named groups, lookarounds and Unicode properties \p{…}. Most of it is the same in Python, PHP (PCRE), Java and C#; Go lacks lookarounds and back-references. The Code panel rewrites named groups and similar differences per language.

Is my text uploaded?

No. Matching runs in a separate thread in your browser and stops after 1 second to guard against catastrophic backtracking; nothing is sent to a server.

regex cheat sheet practical guide and common questions

What does a regex cheat sheet do?

The sheet follows your browser's JavaScript (ECMAScript 2024) syntax, including named groups (?<name>…), lookarounds and Unicode properties \p{…}; every item can be inserted into the tester to try.

Who is this for, and when is it useful?

Developers, marketers and analysts writing data cleaning, form validation, log analysis or SEO rules who forget a piece of syntax and want to check it immediately.

How do I use this regex cheat sheet?

Syntax grouped by characters, anchors, quantifiers, groups, lookarounds, escapes and replacements; click any item to insert it into the tester above and see it work on real text.

How should I interpret the results?

Most syntax is the same in Python, PHP, Java and C#; Go (RE2) has no lookarounds or back-references, and Python writes named groups as (?P<name>…).

Where is the work performed, and which services receive data?

The cheat sheet and tester run in your browser; test text is never uploaded to any server.