Regex Tester

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

About This Tool

The Regex Tester lets you write, test, and debug regular expressions with instant visual feedback. Regular expressions (regex) are powerful pattern-matching sequences used across virtually every programming language for tasks like input validation, text search-and-replace, log parsing, and data extraction.

As you type your pattern and test string, the tool highlights every match in real time. It uses the browser's native RegExp engine — the same engine your JavaScript code uses — so you can be confident results are accurate. All six JavaScript regex 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 regex patterns you can load with one click.

All processing happens client-side. Your patterns and test data never leave your browser.

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. All regex matching runs locally in your browser using the native RegExp object. No data is sent to any server.

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