Toolkist

Regex Tester

Test a pattern against sample text, with live highlighting and group capture.

About the Regex Tester

Write a pattern, paste sample text, and see every match highlighted with its position and capture groups β€” or switch to Replace to preview a substitution. The flavour is JavaScript's own, so what works here works in JavaScript and TypeScript. One feature is worth knowing about before you need it: a pattern with nested quantifiers, such as (a+)+b, can take exponentially long on input that nearly matches, and because the match happens inside the regex engine nothing in JavaScript can interrupt it β€” the page simply stops. This tool screens for that shape before running anything and asks first. The same flaw is a real denial-of-service vector in production code, so a warning here is worth heeding there.

Which flavour of regex is this?

JavaScript's own, as implemented by your browser. Patterns that work here work in JavaScript and TypeScript; PCRE, Python and Go differ in places, most notably around lookbehind and named group syntax.

Why does it warn before running some patterns?

Because a pattern like (a+)+b can take exponentially long on input that almost matches, and once the regex engine starts there is no way for JavaScript to interrupt it β€” the tab simply stops responding. The check looks for that structural shape and asks first. It is a heuristic, so it occasionally warns about a pattern that is fine.

What is catastrophic backtracking?

When a pattern can divide the same input many different ways, the engine tries every division before concluding there is no match. Nested quantifiers and overlapping alternations are the usual causes. The same flaw is a denial-of-service vector in production code, which is why it is worth spotting here.

Is there a limit on the test string?

Yes, 100,000 characters, and matches are capped at 1,000. Both exist because the cost of a bad pattern scales with input length, and because no interface can usefully show more than a thousand matches.

Is my pattern or test data sent anywhere?

No. The regex runs in your browser and nothing is transmitted.

Related: JSON Formatter Β· Base64 Encoder Β· Cron Parser

Keywords: regex tester, regular expression tester, regex match, capture groups, regex replace, javascript regex, redos