Regex Tester

//

2 matches

Contact us at admin@example.com or sales@example.co.uk for help.

Match 1 at 14: admin@example.com

Match 2 at 35: sales@example.co.uk

Replaces only the first match unless the g flag is set — exactly what .replace() would do with this pattern in real code.

About Regex Tester

Type a pattern and a test string and see every match highlighted live, along with its capture groups — plus an optional replace preview using the exact same pattern. Runs entirely in your browser, so text with anything sensitive in it never has to leave your machine.

A regular expression is easy to write and surprisingly easy to get subtly wrong — an unescaped character, a greedy quantifier that grabs more than intended, a capture group in the wrong place. Seeing every match highlighted against real text, immediately, is the fastest way to catch that before it ships in actual code.

This tests real JavaScript `RegExp` semantics specifically (not PCRE, not Python's `re`, not grep) — the exact engine your browser or Node.js code will actually run, since it uses no library of its own, just native `RegExp`/`matchAll`/`replace`. Flags work the same way they do in code: `g` finds every match instead of just the first, `i` ignores case, `m` makes `^`/`$` match line boundaries, `s` lets `.` match newlines.

The replacement field mirrors real `.replace()` behavior exactly — including the easy-to-forget part: without the `g` flag, only the *first* match gets replaced, same as it would in actual code. `$1`, `$2`, and named groups all work in the replacement text.

What you can use it for

  • Check whether a validation pattern actually matches the inputs it's supposed to.
  • See exactly which part of a string a capture group extracts before using it in code.
  • Preview a find-and-replace before running it against a real file or database.
  • Debug why a regex isn't matching what you expect, one flag at a time.
  • Test a pattern against multiple example lines at once.

How it works, step by step

  1. 1

    Enter a pattern and flags

    Written between slashes, like in JavaScript source code.

  2. 2

    Paste a test string

    Every match highlights live, with its index and capture groups listed below.

  3. 3

    Optionally add a replacement

    See exactly what .replace() would produce, $1-style group references included.

Frequently asked questions

Does this use the same regex flavor as Python or PCRE?

No — this tests JavaScript's own `RegExp` engine specifically, the same one your browser or Node.js code actually runs. Most everyday patterns behave identically across flavors, but some features (lookbehind support, named groups, possessive quantifiers) differ between engines.

Why does only the first match get replaced?

Because the `g` (global) flag isn't set — this mirrors real `.replace()` behavior exactly, which only replaces every match when `g` is present. Add `g` to the flags to replace all of them.

What do $1, $2 mean in the replacement?

They refer to the first, second, etc. capture group from the pattern — standard JavaScript replacement syntax. Named groups (`(?<name>...)`) can be referenced as `$<name>`.

Is my text or pattern sent anywhere?

No. Matching, highlighting and the replace preview all run entirely in your browser.