Regex Tester

Write a JavaScript regular expression, paste sample text, and see every match highlighted live — with capture groups and match positions listed below.

regex-tester · live · runs locally
Matches (2)
Contact ada@example.com or lin@toolstack.dev for access. Invalid: not-an-email@nope
  • @8ada@example.com
  • @27lin@toolstack.dev

What this regex tester does

Regular expressions fail silently: an almost-right pattern simply matches the wrong things. The fix is a tight feedback loop, and that is what this tester provides — as you edit the pattern, flags or test text, every match is re-highlighted instantly and listed with its position and capture groups. Invalid patterns show the parser’s error message instead of pretending nothing matched.

The tester runs your pattern with the browser’s own JavaScript regex engine, so what you see here is exactly what String.match, RegExp.exec and String.replace will do in your code.

How to test a regular expression

  1. Type your pattern (no surrounding slashes needed) and any flags.
  2. Paste representative test text — include cases that should not match.
  3. Check the highlights and the match list, including capture groups.
  4. Refine until the matches are exactly right, then copy the pattern into your code.

Building patterns that survive real data

The habit that separates working regex from fragile regex: test against hostile input, not just the happy path. Add lines that are close-but- wrong, empty lines, and punctuation-heavy text. Prefer explicit character classes over the dot, anchor with \b or ^…$ where possible, and keep capture groups minimal. If you are extracting from JSON, validate the document first with the JSON Validator — a real parser beats regex for structured data.

Frequently asked questions

Which regex flavor does this tester use?

JavaScript (ECMAScript), the engine built into your browser. Patterns that work here work in Node.js and frontend code. Most patterns also transfer to Python, Go or Java, but a few features differ — lookbehind support and named-group syntax being common examples.

What do the regex flags mean?

g finds all matches instead of stopping at the first; i makes matching case-insensitive; m lets ^ and $ match at each line break; s lets the dot match newlines; u enables full Unicode mode; y anchors matching at the exact position.

Why does my pattern match too much?

Usually greedy quantifiers: .* grabs as much as possible. Add ? to make it lazy (.*?), or better, replace the dot with a negated class like [^"]* that states exactly what can appear. Anchors (^ $ \b) also stop matches from bleeding into neighboring text.

How do capture groups work?

Parentheses capture the text matched inside them, numbered left to right. This tester lists each match's groups so you can verify you are extracting the right parts — the foundation for using regex in replace operations and parsers.