TK TaskKit
Developer Tools

Regex Tester

Test JavaScript regular expressions with match highlighting, capture groups, and a Web Worker timeout against catastrophic backtracking.

Pattern/

Type a pattern to see a token-by-token breakdown.

Test string
Result
Type a pattern and a test string to see matches.

Inputs stay on this device. Every developer tool on TaskKit runs entirely in your browser. Tokens, payloads, and pasted text are not transmitted to TaskKit servers or third parties.

What this tool does

A JavaScript regular expression tester with live match highlighting, capture-group breakdown, and protection against catastrophic backtracking. The flags input accepts the standard set (g i m s u y), and matches are listed with their start and end indices and any named or numbered groups.

When you'd use it

  • Drafting a regex against a representative sample before pasting it into code.
  • Confirming what a regex from someone else actually matches (and what it doesn't).
  • Tightening a pattern that was too greedy or too loose in production.
  • Practicing the JavaScript flavor specifically, since each language has subtly different semantics.

How it works

The pattern is compiled with new RegExp(pattern, flags) and then run against the test text. Matching happens inside a Web Worker with a 1-second timeout — if the pattern triggers catastrophic backtracking on the supplied input, the worker is terminated and you see a "regex took too long" error instead of a frozen tab. This is a real concern for patterns like (a+)+b against long inputs of a.

Notes

Why is a Web Worker needed? Browser regex engines don't expose a timeout, and a single slow regex can hang the main thread for tens of seconds. Running matching inside a Worker means we can worker.terminate() and stay responsive.

Does this support Perl/PCRE features? No — only what JavaScript supports. \K, atomic groups, possessive quantifiers, and recursive patterns are not part of the JS regex grammar. Lookbehind and named groups are.

My regex matches in this tool but not in my code. Check the flags. The u flag changes how some character classes match Unicode; the g flag affects state across calls when you reuse the regex object.

Related tools