freetools.guru

Regex Tester

Test JavaScript regular expressions instantly in your browser. Build and debug patterns with live match highlighting, capture groups, named groups and match indices — plus a JavaScript replacement preview and a hard timeout that stops catastrophic backtracking. Private, no uploads.

Regular Expression

Flags

//g

Tip: press Ctrl + Enter to run

Hard limit 5,000 matches.

JavaScript tokens: $&, $1, $<name>.

Results

Ready

Regex syntax follows JavaScript regular expressions. Expressions run in a Web Worker and are compiled with new RegExp() — never eval — so your text is never executed as code.

Everything runs locally in your browser. Your pattern and test text never leave your device, and no data is uploaded.

Expressions with catastrophic backtracking are interrupted by a hard timeout, so the page never freezes. Regex is for matching text, not for security — never rely on a regular expression as your only input filter.

How it works

  1. 1Enter a pattern and flags. Type a JavaScript regular expression and toggle the flags you need — global, case-insensitive, multiline, dotAll, Unicode, sticky, and the d (indices) and v (Unicode sets) flags when your browser supports them.
  2. 2Add test text. Paste up to 500,000 characters of text to search. Optionally add a replacement string using JavaScript tokens such as $&, $1 or $<name> to preview text.replace().
  3. 3Run the test. Click Test Regex (or press Ctrl+Enter). The expression is compiled with new RegExp() inside a Web Worker, and matches, capture groups, named groups and indices are returned without ever blocking the page.
  4. 4Inspect, copy or download. Review highlighted matches, groups and a replacement preview, copy the pattern or any match, and download a regex-results.json file — all locally in your browser.

Best practices

  • Remember that regex syntax follows JavaScript regular expressions — behavior that differs in PCRE, Python, .NET or Java is not replicated.
  • Turn on the global (g) flag to find every match; with global off the tool reports only the first match, which is often all you need when debugging.
  • Use the d flag to see the start and end indices of every capture group directly in the highlighted text.
  • Use the Unicode (u) flag for Unicode property escapes such as \p{L} and \p{Script=Tamil}, and keep the v flag for advanced Unicode sets when your browser supports it.
  • Test text up to 500,000 characters is supported, and match collection stops at the configured limit to keep results readable.
  • Expressions with catastrophic backtracking are interrupted by a hard timeout, so the page never freezes — but avoid patterns like (a+)+$ on long inputs anyway.
  • Regex is for matching text, not for security — never rely on a regular expression as your only input filter or sanitizer.
  • Everything runs locally in your browser in a Web Worker — nothing is uploaded, and your text is never executed as code.

Frequently Asked Questions

What does Regex Tester do?
It lets you test and debug JavaScript regular expressions locally in your browser. Type a pattern, pick the flags you need, and paste some test text — the tool runs the expression in a Web Worker and shows every match with its index, end and length, plus capture groups, named groups and match indices.
Which regex syntax is supported?
The expression is compiled with JavaScript's new RegExp() — never eval — so it follows JavaScript regular expression syntax exactly. Lookarounds, backreferences, named groups, Unicode property escapes (with the u flag) and more are supported. Behavior that differs in PCRE, Python, .NET or Java is deliberately not replicated.
What do the flags mean?
g finds every match instead of only the first, i ignores case, m makes ^ and $ match per line, s lets . match newlines, u enables Unicode-aware matching and \p{...} property escapes, y makes matching sticky to the current position, d adds the start/end indices of the match and each group, and v enables advanced Unicode sets. The d and v flags appear only when your browser supports them.
How do I see the index of each match?
Every match row shows its start index, exclusive end and length in the test text. With the d flag enabled, the match and each capture group are also highlighted with their exact [start, end) ranges right in the text.
What are capture groups and named groups?
Capture groups are the parts of the pattern inside parentheses, shown as Group 0, Group 1 and so on. Named groups use (?<name>...) syntax and are shown with their names. A group that did not participate in a match (for example an optional group that was skipped) is shown as undefined.
How does the replacement preview work?
Type a replacement string and the tool previews text.replace() with it. JavaScript tokens such as $& (the whole match), $1 (the first capture group) and $<name> (a named group) work exactly as in String.prototype.replace. The preview is read-only plain text.
Why does the tool time out on some expressions?
Some patterns can cause catastrophic backtracking, where the engine tries an astronomically large number of combinations. To keep the page responsive, every run is stopped after the selected timeout (250 ms to 2000 ms) by terminating the worker, and the tool explains that the expression may be causing excessive backtracking.
What does a zero-length match mean?
An expression like a* or ^ can match an empty string, which produces matches with an empty value and an index but no characters. The tool shows these safely with their position, and never gets stuck: after each empty match it advances by one code point so the run always finishes.
Can I match Tamil or other Unicode text?
Yes. With the u flag you can use Unicode property escapes such as \p{Script=Tamil} to match Tamil words, and the tool includes a Tamil example pattern. Test text up to 500,000 characters is supported and emoji are handled as full code points.
Is my pattern or text uploaded anywhere?
No. Everything runs locally in your browser inside a Web Worker. No server call is made, nothing is uploaded, no account is required, and your text is never executed as code — it is only searched by the regular expression.
Is regex a security tool?
No. Regular expressions match text patterns; they are not a substitute for proper input validation, encoding or a security filter. Never rely on a regex alone to sanitize or secure data.

Related Tools

Supported expressions

Test any JavaScript regular expression — literals, character classes, anchors, quantifiers, alternation, lookarounds, backreferences, and Unicode property escapes such as \p{L} and \p{Script=Tamil} — directly in your browser. All standard flags are supported (g, i, m, s, u, y), plus the d (match indices) and v (Unicode sets) flags when the runtime accepts them. Up to 500,000 characters of test text and up to 5,000 matches per run are supported, with a hard timeout that interrupts catastrophic backtracking. The expression is compiled with new RegExp() — never eval — inside a Web Worker.

Privacy & data removal

Your pattern and test text are evaluated entirely in your browser inside a Web Worker and are never uploaded to any server. No account is required to use the Regex Tester, we never store or share your patterns or text, and your input is never executed as code.