glunty

Regex Tester (JS, live match highlighting)

Build a pattern, watch matches highlight live, and inspect every capture group. Runs locally in your browser.

Flags

What this tool does

Tests a JavaScript regular expression against sample text, live, entirely in your browser. As you type a pattern or edit the text, the tool rebuilds the RegExp, highlights every match inside the string, and lists each match with its index, its full matched text, and every capture group (numbered, plus named groups when your pattern uses them). Invalid patterns show a clear inline error instead of crashing. Nothing is uploaded; matching runs on the native engine in your browser.

How to use it

Type your pattern into the Regular expression box (no slashes needed), tick the flags you want, and paste text into the Test string box. Results update on every keystroke. For example, the pattern (\d+) with the g flag against a12b3 highlights 12 and 3, and the match list shows each one with capture group 1. Once you know what a pattern matches, run it through the AI regex explainer to confirm it means what you think.

Common use cases

  • Checking that a validation pattern accepts the inputs you expect and rejects the rest.
  • Pulling fields out of log lines or CSV rows with capture groups.
  • Debugging why a search-and-replace matched too much or too little.
  • Learning how flags like i, m, and s change behavior.
  • Confirming a named group like (?<year>\d4) captures the right slice.

Common pitfalls

  • Forgetting the g flag. Without g, only the first match is reported. Turn it on when you expect several matches or a count.
  • Unescaped special characters. Characters like ., (, +, and ? are operators. To match them literally, escape with a backslash, for example \. for a literal dot.
  • Greedy quantifiers. .* matches as much as it can. If a match swallows more than intended, try a lazy quantifier like .*? or a tighter character class.
  • Zero-length matches. A pattern that can match nothing (for example an empty group) matches at many positions. This tester advances past each empty match so it never loops, and marks the spot with a thin caret.

Frequently asked questions

What does the global (g) flag change?
Without the g flag, the tester reports only the first match. With g, it uses matchAll to scan the whole string and reports every non-overlapping match. Turning g on is what lets you see counts and iterate over all results rather than just the first one.
How do I read the capture groups in the results?
Each match lists its numbered groups (group 1, group 2, and so on) in the order the opening parentheses appear in the pattern. A group that did not participate in the match shows as undefined. Named groups written as (?<name>...) appear under their name in addition to a number.
What is the difference between this tester and the regex explainer?
This tester runs your pattern against real text so you can see what actually matches. The regex explainer at /regex-explainer turns a pattern into a plain-English description of what it is meant to match. Testing plus explaining catches both logic bugs and misunderstandings, which is why the two tools are better used together.
Why does my pattern report an error?
The tester builds a live RegExp and catches any syntax error, such as an unbalanced parenthesis or an invalid group. The exact browser message appears inline and the previous highlight is cleared rather than crashing the page. Fix the pattern and the error clears on the next keystroke.
What do the s, u, and y flags do?
The s (dotAll) flag lets a dot match newline characters. The u (unicode) flag treats the pattern as Unicode code points and enables the extended Unicode escapes and property classes. The y (sticky) flag anchors each match attempt to the current position instead of searching forward through the string.
How are zero-length matches handled?
Patterns like an empty alternation or a lookahead can match without consuming characters. The engine advances past each zero-length match so the scan cannot loop forever, and the tester marks the position with a thin caret so you can still see where it matched.
Is my test string sent anywhere?
No. The pattern and the test string never leave your browser. Matching uses the native JavaScript RegExp engine on your machine, so the tool also works offline once the page has loaded.

Embed this tool

Free for any use; attribution appreciated. Paste this on your site:

The embed runs the same tool that lives at this URL. No tracking; no ads inside the embed. Resize height as needed for your layout.

Cite this tool

For academic, journalistic, or technical references. Pick a format:

Citations use 2026 as the publication year. Access date is left as a fillable placeholder where the citation style expects one.

Embedded tool from glunty.com