gettoolz.app

Regex Tester

Test a regular expression against text with live match highlighting.

Part of developer tools.

Pattern
//g
Flags
Test text

Enter a pattern above to start matching.

How the matching works

The pattern and flags are compiled with JavaScript's own RegExp engine — the same one your browser and Node.js use — so anything valid in a script works here unchanged. With the g flag on, the tool repeatedly finds the next match and moves past the last one, including handling matches of zero length (a pattern like x* can match an empty string at every position) without getting stuck in place. Each match reports its position in the text, the matched substring, and its capture groups: numbered groups start at 1 in the order their parentheses open, and named groups ((?<name>…)) are listed by name alongside them.

Flags: g, i, m, s

g (global) returns every match instead of stopping at the first one — without it, a pattern behaves exactly like a single call to RegExp.exec. i ignores case. m (multiline) makes ^ and $ match at the start and end of each line rather than only the start and end of the whole text. s (dot all) lets . match newline characters too, which it otherwise does not.

Time and size limits

Some patterns take exponential time on the wrong input: nested quantifiers such as (a+)+$ run against a long line of as ending in a ! make the engine try every way of splitting the as before giving up. That is called catastrophic backtracking, and a regex engine can't be interrupted from inside a single match. So the matching doesn't run on the page itself but in a Web Worker, a background thread of your browser: the page stays responsive while it works, a new keystroke cancels the search still running, and a search still going after 1 second is stopped and reported as too costly instead of freezing the tab. That holds for a pattern opened from a shared link too.

Test text is also capped at 100,000 characters, and a single run at 10,000 matches, so that an unbounded result (say, a pattern that matches an empty string at every position across a huge text) can't produce an array too large to send back and display.

Nothing leaves your browser

The pattern and the text you paste are matched locally in JavaScript — neither is sent anywhere, which matters when you're testing a regex against something you'd rather not upload, like log lines with real user data or a config file with credentials in it. Reloading the page clears everything.

Common regexes, tested

Ready-made patterns, each with the inputs it accepts and rejects — verified against the pattern when the site is built — and the cases where it falls short. Paste your text with the pattern still empty, and the tester offers the ones that accept every line: