ToolFox

Regex Tester

Test a regular expression against sample text and see every match, its position and captured groups.

2 matches
  • match: 42 (index 6)
  • match: 108 (index 26)

How it works

Your pattern and flags are compiled into a native JavaScript RegExp and run against the test text. With the global (g) flag, every match is found in order, each shown with its match text, character index and any captured groups; without g, only the first match is returned, matching how JavaScript itself behaves. Invalid patterns — like an unclosed bracket — surface the engine's own error message instead of a blank result.

Example

Matching \d+ with the g flag against "Order 42 shipped, invoice 108 paid." finds two matches — "42" at index 6 and "108" at index 27. Matching (\w+)@(\w+) against an email-like string captures the username and domain as separate groups.

Frequently asked questions

Which regex flavour does this use?

JavaScript's native RegExp engine — the same one that runs in Chrome, Firefox and Node.js. Syntax may differ slightly from PCRE or Python's re module.

Why did I only get one match?

Without the g (global) flag, JavaScript regexes stop after the first match by design — add g to find every occurrence.

What happens with an invalid pattern?

The tool catches the JavaScript engine's SyntaxError and shows its message, such as an unterminated group, instead of silently failing.

Is there a limit on matches?

Yes — results are capped at 1,000 matches to keep the page responsive on pathological patterns or huge inputs.

Related tools