How to use the Regex Tester
- Type your pattern between the slashes. Toggle flags like g (all matches), i (ignore case) and m (multiline).
- Paste the text to search in the Test string box. Matches are highlighted in alternating colors.
- See each match with its position and capture groups on the right.
- Tick Replace to preview a replacement using
$1,$<name>or$&.
Regex cheat sheet
. | Any character except a line break (add the s flag to include line breaks) |
|---|---|
\d \w \s | A digit, a word character (letter, digit or _), a whitespace character. Capitals (\D \W \S) mean the opposite. |
[abc] [^abc] [a-z] | One of a, b or c; anything except them; any lowercase letter |
^ $ | Start and end of the text (or of each line with the m flag) |
\b | A word boundary |
* + ? {2,5} | 0 or more, 1 or more, optional, between 2 and 5 times. Add ? to make them lazy, e.g. .*? |
(…) (?:…) (?<name>…) | Capture group, non-capturing group, named group |
a|b | a or b |
(?=…) (?!…) (?<=…) (?<!…) | Lookahead, negative lookahead, lookbehind, negative lookbehind |
Protected from catastrophic backtracking
Some patterns, such as (a+)+$, can take exponential time on certain inputs and freeze a browser tab. Here, matching runs in a background worker and is stopped after two seconds, with a warning, so the page stays responsive.
JavaScript vs other regex flavors
Most syntax is shared with Python, PHP (PCRE), Java and .NET. Differences to watch: JavaScript has no possessive quantifiers or atomic groups, and inline flags like (?i) are newer and not supported everywhere. Named groups use (?<name>…), which Python writes as (?P<name>…).
Frequently asked questions
Which regex flavor does this use?
JavaScript (ECMAScript), as built into your browser. It matches what you'll get in Chrome, Firefox, Safari, Node.js and Deno.
Why does it only find one match?
Turn on the <b>g</b> (global) flag to find every match instead of just the first.
How do I match across multiple lines?
Use the <b>m</b> flag so <code>^</code> and <code>$</code> match at each line, and the <b>s</b> flag so <code>.</code> also matches line breaks.
Is my text uploaded?
No. Everything runs in your browser.