Regex Tester

Test regular expressions with live match highlighting, capture groups, and replace preview. Supports all JavaScript regex flags.

About This Tool

Debugging a regex like ^(?:[a-z0-9]+(?:\.[a-z0-9]+)*)@(?:[a-z0-9-]+\.)+[a-z]{2,}$ in your head is painful. The Regex Tester gives you real-time match highlighting, numbered and named capture groups, and a live replace preview — so you can see exactly what your pattern matches (and misses) as you type.

The tool runs on your browser's native RegExp engine — the same engine your JavaScript or Node.js code uses — so results are identical to production. All six JavaScript flags are supported: global (g), case-insensitive (i), multiline (m), dotAll (s), unicode (u), and sticky (y).

The Match view shows highlighted matches in context plus a detailed breakdown of each match with its index and capture groups — both numbered and named. The Replace view lets you enter a replacement string (using $1, $2, etc. for back-references) and see the result in real time. The Library view provides a curated collection of common patterns you can load with one click.

All processing stays client-side. Your patterns and test data never leave your browser. Once you've validated your data format, you can process it with the JSON Formatter or encode special characters with the URL Encoder. Need to validate a UUID pattern you just wrote? Test it against sample IDs from the UUID Generator.

How to Use

  1. Enter a regex pattern in the pattern input. The pattern is shown between forward-slash delimiters.
  2. Toggle flags by clicking the flag badges (g, i, m, s, u, y).
  3. Type or paste your test string. Matches are highlighted instantly.
  4. Review the Matches & Capture Groups section for detailed match info including group values and indices.
  5. Switch to Replace mode to enter a replacement string and see the transformed output.
  6. Use the Library to quickly load common patterns like email, URL, IP address, and more.
  7. Click Copy or press Ctrl+Shift+C to copy the full regex with flags.

FAQ

Which regex engine does this tool use?

This tool uses your browser's built-in JavaScript RegExp engine. Results will match exactly what you'd get running the same regex in Node.js or any modern browser.

What do the flags mean?

g (global) finds all matches, not just the first. i makes matching case-insensitive. m makes ^ and $ match line boundaries. s makes . match newlines. u enables full Unicode matching. y (sticky) matches only at lastIndex.

How do capture groups work?

Parentheses () create capture groups. Each group captures the text matched by the sub-pattern inside. Groups are numbered left-to-right starting at 1. Named groups use the syntax (?<name>...) and appear under their name in the results.

What are back-references in replacement?

In the replacement string, $1, $2, etc. refer to the text captured by the corresponding numbered group. $& refers to the entire match. $` and $' refer to text before and after the match.

Is my data safe?

Yes. Pattern matching runs locally via the browser's built-in JavaScript RegExp constructor — the same API available in any browser DevTools console. No network requests are made, and no data is logged or stored anywhere outside your machine.

Can regex patterns cause the browser to hang?

Certain patterns with nested quantifiers (like (a+)+) can cause catastrophic backtracking on some inputs. If the browser becomes unresponsive, reload the page and simplify your pattern. This tool limits match iterations to prevent infinite loops.

Related Tools