Regex tester

Build and debug regular expressions live — every match highlighted and every capture group broken down, privately in your browser.

Match results Matches found: 0

What a regex tester does and how this one works

A regular expression is a compact pattern language for describing the shape of text: an email address, a hex colour, a date, a price. Instead of reading a string character by character, you hand the engine a pattern and it reports where — and whether — that shape appears. The hard part is that a tiny pattern can behave in surprising ways, so the fastest way to get one right is to watch it run against real input. That is exactly what this tool does: as you type, it compiles your pattern with the browser's native RegExp engine, highlights every match in the test text, and lists each match with its position and capture groups.

A worked example

Take the default pattern [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} with the flags gm. Paste a paragraph containing [email protected] and [email protected] and both light up. The g flag tells the engine to keep scanning after the first hit, so you see every address rather than just one. Wrap the local part in parentheses — ([a-zA-Z0-9._%+-]+)@ — and that captured slice (for example support) appears as Group 1 in the results table, alongside the full match and its [start, end] index range.

The flags you can add

FlagNameEffect
gGlobalFind every match, not just the first.
iIgnore caseTreat A and a as equal.
mMultilineMake ^ and $ match the start and end of each line.
sDotAllLet . match newline characters too.
uUnicodeEnable correct handling of code points and \p{…} escapes.
yStickyMatch only at the exact current position in the text.

Greedy, lazy and catastrophic backtracking

Quantifiers like * and + are greedy by default — they grab as much text as possible and then give it back only if the rest of the pattern fails. Add a ? (as in .*?) to make them lazy, stopping at the first point that lets the match succeed. Beware nesting quantifiers such as (a+)+ against non-matching input: the engine can try an exponential number of paths before giving up, a performance trap known as catastrophic backtracking. Anchor your patterns with ^ and $ and prefer specific character classes over broad wildcards to keep matching fast.

Privacy note: everything here runs locally with no server round-trip and no logging of your input. Your pattern and test text — even if it is a chunk of a production log — stay in this browser tab and are gone the moment you close it.

Frequently asked questions

Is my test text or pattern sent to a server?

No. The regular expression is compiled and run entirely in your browser using the native JavaScript RegExp engine. Your pattern and the text you test against never leave your device, so it is safe to paste log lines, emails or other sensitive data.

Which regex flavour does this tool use?

It uses the ECMAScript (JavaScript) flavour built into your browser. That means features like lookbehind, named groups (?<name>...), the d, g, i, m, s, u and y flags, and Unicode property escapes are supported, while PCRE-only constructs such as possessive quantifiers or recursion are not.

Why do I get "nothing to repeat" or "invalid group" errors?

Those come straight from the RegExp compiler. "Nothing to repeat" usually means a quantifier like * or + has no preceding token; "invalid group" often means an unbalanced parenthesis. The red error banner shows the exact engine message so you can pinpoint the problem.

What do the index ranges in the results table mean?

Each match shows a [start, end] pair — the zero-based character offset where the match begins and the offset just after it ends. The length of the match is simply end minus start, which is handy when you slice the same string in code.

How do capturing groups show up here?

Every parenthesised group in your pattern becomes a numbered column entry. Group 1 is the first opening parenthesis, group 2 the second, and so on. Non-participating groups (for example an alternative that did not match) are shown as empty.

Why does the global flag matter for finding all matches?

Without the g flag the engine stops at the first match, so the tool reports at most one result. Add g to scan the whole text and highlight every occurrence. Combine it with m to make ^ and $ anchor to each line.