Category: Developer tools

JavaScript Regex Tester

System ideaMissing a tool?

Match text, zero-based indexes, capture groups and a String.replace preview

Test a JavaScript RegExp against your sample text: toggle g, i, m, s, u and y, read matches with indexes and capture groups, and preview a replacement. All local.

Flags /g
3 matches
  1. ada@example.comat 0
    $1 ada$2 example.com
  2. grace@example.orgat 25
    $1 grace$2 example.org
  3. support@localtools.devat 50
    $1 support$2 localtools.dev
Replace preview
ada [at] example.com wrote to grace [at] example.org and to support [at] localtools.dev

Everything on this page is processed in your browser. Nothing is uploaded.

What this tool does

This is a tester built on the browser's own JavaScript RegExp engine. Write a pattern without the wrapping slashes, toggle the flags you need — g, i, m, s, u and y are all available — and paste the text you want to run it against. Every match comes back with the matched text, its zero-based index in the string, and the contents of its numbered and named capture groups. Below that, a replacement template field previews the String.replace output, so $1, $2 and named references behave exactly as they will in your code. If the pattern will not compile, the RegExp syntax error is shown rather than an empty result, and the match list is capped at 500 entries so a runaway pattern cannot flood the page. The boundaries deserve to be explicit, because the pages that rank alongside this one are usually a different class of tool. This is JavaScript only: PCRE, Python, RE2 and .NET are not emulated, so anywhere those engines differ, the JavaScript rules apply. It is not a debugger: there is no step-through execution view, no railroad diagram, no performance timing and no ReDoS safety audit. It takes typed input only, with no file upload, no multiline corpus batch and no remote URL. And it will not write a pattern for you or explain in prose what one does. Patterns, test strings and replacement output stay in your browser and are never uploaded to LocalTools.

How to use it

  1. Write the pattern without wrapping slashes and toggle the flags you need from g, i, m, s, u and y.
  2. Paste your test string and read each match with its zero-based index and its numbered or named capture groups.
  3. Add a replacement template to preview String.replace output; syntax errors are surfaced and the match list stops at 500 entries.

Privacy

This tool runs entirely in your browser. Your input is never uploaded, stored or shared — closing the tab removes it.

Frequently asked questions

Which regex syntax does this page use?
The browser's native JavaScript RegExp, and only that. PCRE, Python, RE2 and .NET are not emulated, so a pattern that relies on another engine's syntax may behave differently or fail to compile here.
What do the flags g, i, m, s, u and y mean?
g finds every match instead of the first, i ignores case, m makes ^ and $ match line boundaries, s lets the dot match newlines, u enables Unicode mode and y anchors the search at lastIndex. All six can be toggled here.
How do capture groups work?
Each parenthesised part of the pattern captures a substring, numbered from left to right, and named groups get a label. Both are listed for every match and both can be referenced in the replacement template.
Why do I only see one match?
Without the global flag a RegExp stops at the first match. Turn on g to list them all. The same flag governs the replacement preview: without it, only the first occurrence is replaced.
Is my data safe when using this regex tester?
Yes. The pattern, the test string and the replacement output stay in your browser and are never uploaded to LocalTools. There is also no file upload or URL import, so there is nothing to send.