Test patterns safely
Type a JavaScript regular expression and its flags, paste some test text, and every match is highlighted as you type. The match list shows each match’s position, numbered capture groups ($1, $2…) and named groups ((?<year>\d{4})). Add a replacement to preview String.replace output, using $1, $<name> and $&.
Flags: g global, i ignore case, m multiline (^ and $ match at line breaks), s dotAll (. matches newlines), u Unicode (enables \p{L} and correct handling of emoji), y sticky, d indices, v set notation.
Protection against runaway patterns
Some patterns take exponential time on certain inputs (the classic example is (a+)+$ against a long string of a’s followed by a b). This is called catastrophic backtracking, and it’s behind real outages (and “ReDoS” attacks). In most online testers such a pattern freezes the browser tab.
Here, matching runs in a separate Web Worker that is terminated after 1.5 seconds, with an explanation instead of a frozen page. If you hit that limit, look for nested quantifiers and overlapping alternatives, and make them more specific.
The cheat sheet beside the results covers the syntax most people look up. This tester uses your browser’s own JavaScript engine, so behaviour matches what your code will do in browsers and Node.js; other flavours (PCRE, Python, .NET) differ in details such as lookbehind support and named-group syntax.
Questions
Which regex flavour does this use?
JavaScript (ECMAScript), using your browser’s own engine, so results match browsers and Node.js.
Why did my pattern time out?
It probably causes catastrophic backtracking, often from nested quantifiers like (a+)+ or (.). The tester stops it after 1.5 seconds so your page stays responsive.
How do I use capture groups in the replacement?
Use $1, $2… for numbered groups, $
Last reviewed · How Textkiln tools work