About the Regex Tester
Write a regular expression and see every match highlighted in your test text as you type. The match table lists the position of each match and the value of every capture group, including named groups, so you can debug complex patterns quickly.
Toggle the g, i, m, s and u flags, and switch on Replace to preview the result of a search-and-replace using $1 or $<name> references. Patterns run in a background worker, so a runaway pattern is stopped instead of freezing the page. Everything runs locally in your browser — nothing you paste is sent to a server.
Last reviewed November 21, 2026
How a pattern is run
Your pattern and flags are passed to new RegExp(pattern, flags) inside a fresh Web Worker, a background thread with no access to the page. That means the behaviour is exactly that of the JavaScript engine in your browser, as specified by ECMA-262. With the g flag the worker collects every match using matchAll; without it, only the first match is found, just as RegExp.exec would return. The first 1,000 matches are kept (the table lists the first 200), and if the worker has not answered within 1.5 seconds it is terminated.
Five flags are offered: g, i, m, s and u. The sticky y flag, the d flag (match indices) and the newer v flag are not available as toggles. Empty matches, which patterns like \d* produce between characters, are counted in the match total but are not highlighted, because there is nothing to highlight.
Worked example: reformatting dates
Pattern, with the g flag on:
(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
Test text: Released 2026-11-21, patched 2026-12-03.
| # | Match | Index | Groups |
|---|
| 1 | 2026-11-21 | 9 | year: 2026, month: 11, day: 21 |
| 2 | 2026-12-03 | 29 | year: 2026, month: 12, day: 03 |
Turn on Replace with $<day>/$<month>/$<year> and the output is Released 21/11/2026, patched 03/12/2026. Switch the g flag off and only the first date is replaced, because String.replace with a non-global pattern stops after one substitution. Besides $1 and $<name>, the replacement string understands $& (the whole match), $` and $' (the text before and after the match) and $$ for a literal dollar sign.
The index column counts UTF-16 code units, as JavaScript strings do. An emoji earlier in the text counts as 2, which matters if you use the index to slice the string in another language.
JavaScript-specific gotchas
- \w and \b are ASCII-only. /^\w+$/ does not match café, even with the u flag. Use Unicode property escapes such as \p{L} for letters, and turn on u: without it, \p{L} silently matches the literal text p{L}.
- The dot misses newlines and half-matches emoji. Without s, . stops at line breaks. Without u, . matches one UTF-16 code unit, so it captures half of an emoji; with u it captures the whole character.
- ^ and $ mean start and end of the whole text unless m is on. A pattern that works on one line and fails on a pasted multi-line log usually needs m.
- Greedy versus lazy. On <b>one</b><b>two</b>, the pattern <b>.*</b> matches the entire string, while <b>.*?</b> stops at the first closing tag.
- Escaping depends on where the pattern goes. Type the pattern here as it would appear between slashes. Inside a JavaScript string passed to new RegExp, every backslash must be doubled: \d becomes "\\d".
- Lookbehind and named groups are supported in all current browsers; possessive quantifiers and atomic groups, common in PCRE and Java, are not.
Catastrophic backtracking
Patterns with a quantifier inside another quantifier, such as (a+)+$ or (\w+\s?)+$, can need an exponential number of steps when the input almost matches. A few dozen a’s followed by ! can keep (a+)+$ busy for seconds or far longer. This tester survives because the worker is killed; a server does not. OWASP lists this as Regular expression Denial of Service (ReDoS). If the tester times out on realistic input, rewrite the pattern so each character can be matched in only one way, for example (a+)+$ as a+$, and never run user-supplied patterns on a server without a time limit.
For structured formats, prefer a parser to a regex: the JSON formatter for JSON, the URL decoder for query strings, and the CSV converter for delimited data with quoted fields.
How to use the Regex Tester
- Type your regular expression without the surrounding slashes.
- Turn on the flags you need, for example g for all matches and i to ignore case.
- Paste your test text and check the highlighted matches and groups.
- Optionally turn on Replace to preview a substitution and copy the output.
Frequently asked questions
Which regex flavour does this use?
JavaScript (ECMAScript), as used in browsers and Node.js. Most syntax is shared with PCRE, Python and Java, but some features such as possessive quantifiers are not available.
What do the flags mean?
g finds all matches instead of the first, i ignores upper/lower case, m makes ^ and $ match at line breaks, s lets . match newlines, and u enables full Unicode support.
Why was my pattern stopped?
Patterns with nested quantifiers like (a+)+ can take exponential time on some inputs (catastrophic backtracking). The tester stops any pattern that runs longer than 1.5 seconds.