MUTools

Text

Regex Tester

Regex Tester is a tool that takes a regular expression and a sample text and instantly shows matched substrings highlighted in place, the contents of every capture group, a replacement preview, and a per-token explanation of the pattern. It is built for everyday needs: designing form validation in a web app, extracting IDs from logs, doing one-off bulk replacements in a document, and learning regex by trial and error.

g
Flags
Regex presets
Test text
Enter a pattern and test text to see match results here.
Pattern explanation

Enter a pattern to see per-token explanations here.

Save the current pattern, flags, test text, and replacement template in the URL to share with a link.

Your pattern and text are processed entirely in your browser and never sent to any server.

About Regex Tester

Regex Tester is a tool that takes a regular expression and a sample text and instantly shows matched substrings highlighted in place, the contents of every capture group, a replacement preview, and a per-token explanation of the pattern. It is built for everyday needs: designing form validation in a web app, extracting IDs from logs, doing one-off bulk replacements in a document, and learning regex by trial and error.

You can toggle the g / i / m / s / u / y flags individually. When the pattern is invalid, an inline error tells you exactly what went wrong instead of crashing the page. The number of matches, the number of capture groups, and the execution time in milliseconds are shown alongside the results, so you can sanity-check complex patterns or get a rough feel for performance.

Common patterns — email address, URL, Japanese phone number, postal code, IPv4, date, HTML tag, and hex color code — are one-click presets. In the replacement template you can use $& for the whole match, $1 $2 for numbered captures, and $<name> for named captures; the result switches between the "Match results" and "Replacement" tabs. The "Copy share URL" button packs the current pattern, flags, test text, and replacement template into the URL so you can share the exact view with a teammate.

Everything happens locally in your browser. Your pattern and your test text are never sent to a server, so you can safely try regexes against confidential logs or text that contains personal data. Runs entirely in your browser.

How to use

  1. Enter a regex into the Pattern field. You can also insert email, URL, and other common patterns from the preset menu with one click.
  2. Toggle the g / i / m / s / u / y flags on the right to control global matching, case sensitivity, and other behavior.
  3. Paste the text you want to match into the Test text field. Use the Insert sample button for an instant working example.
  4. The result area below highlights every match and shows the count, capture groups, and execution time.
  5. Switch to the Replacement tab and enter a replacement template (which can reference captures with $1 or $&) to see a live replacement preview.
  6. Open Pattern explanation to see each construct in the pattern broken down into a plain-English description.
  7. Click Copy share URL to bundle the current pattern, flags, test text, and replacement template into a URL, so anyone can open the same view from one link.

Use cases

  • Web engineers prototyping form-validation regexes against the strings users actually submit.
  • Operators extracting IDs, paths, and status codes from server or access logs.
  • Writers and editors safely previewing bulk replacements across drafts or CSV data before applying them.
  • Team leads sharing regex examples and test cases by URL during PR reviews or study sessions.
  • Learners stepping through regex constructs one at a time while reading the per-token explanation.

Notes

  • This tool uses the standard JavaScript regular expression engine (ECMAScript RegExp). PCRE- or Oniguruma-specific constructs such as \K and variable-length lookbehinds are not supported.
  • When the g flag is off, only the first match is found and only the first occurrence is replaced. Turn on the g flag to act on every match.
  • Turning on the u flag enables surrogate-pair and Unicode property (\p{...}) support, but tightens escape rules inside character classes. If behavior changes unexpectedly, check the u flag.
  • Test text longer than 500,000 characters is cut off before execution to avoid runaway computation. Matches are also capped at 10,000 results.
  • The shareable URL includes the test text as a query string. Confirm that it is safe to share before sending the link. Very long inputs are automatically dropped from the URL with a notice.
  • Pattern explanation covers the core constructs (character classes, quantifiers, groups, alternation, character sets). Lookahead, lookbehind, and Unicode properties are shown as Unsupported syntax with the raw source.

FAQ

Is the pattern or test text sent to a server?
No. Compilation, matching, replacement, explanation, and timing all happen inside your browser. You can safely try regexes against confidential logs or text containing personal data.
Is there a PCRE mode?
No, this tool only supports the JavaScript RegExp engine built into your browser. PCRE-only constructs such as \K, variable-length lookbehinds, and recursion are not available. For front-end and validation work, what you see here matches production behavior exactly.
Why does only one match or replacement appear when I have not set the g flag?
JavaScript regular expressions act on only the first occurrence when the g flag is off. Turn on the g flag in the flag panel to match or replace every occurrence. A hint is shown on both the match and replacement tabs when g is off.
Will the share URL reproduce the same pattern and result for the person I send it to?
Yes. The link embeds the current pattern, flags, test text, and replacement template as query parameters, so the recipient sees the same match and replacement results immediately. Very long test text is automatically dropped from the URL.
Why does the execution time in milliseconds vary slightly between runs?
Browser internal optimizations (JIT warmup), CPU sharing with other tabs and tasks, and timer-resolution limits all introduce small variance. Use the number as a comparative signal — for example, when you change a pattern — rather than an absolute measurement.