ZapKit

Regex Tester

Build and debug JavaScript regular expressions against your own text, with every match highlighted, capture groups listed and a live replace preview.

What is a regex tester?

A regex tester lets you try a regular expression, a compact pattern for finding or validating text, against sample text and see immediately what it matches. Regular expressions validate emails and phone numbers, extract data from logs, power search-and-replace in editors and route URLs, and they're notoriously easy to get subtly wrong.

This tester highlights every match, lists each match's position and capture groups including named ones, and previews a replacement. It runs your pattern in the browser's own JavaScript engine, in a separate thread with a time limit, so even a runaway pattern can't lock the page.

How to use the Regex Tester

  1. 1.Write the pattern

    Type it without slashes and tick the flags you need, such as g for all matches or i to ignore case.

  2. 2.Add test text

    Matches are highlighted as you type, with each one's position and groups listed.

  3. 3.Try a replacement

    Use $1, $<name> or $& in the replacement to see the result.

Example: pulling user and domain from emails

The default pattern (?<user>[\w.+-]+)@(?<domain>[\w-]+\.[\w.]+) with the g flag:

Match 1
asha@example.com (user asha, domain example.com)
Match 2
ravi.k@mail.co.in (user ravi.k, domain mail.co.in)
Not matched
hello@ and @example.com
Replacement <$<user> at $<domain>>
<asha at example.com>

The incomplete addresses on the second line are correctly ignored.

Runs safely in a separate thread

Matching runs in a Web Worker with a one-second limit. Patterns such as (a+)+$ can take exponential time on some inputs, a problem called catastrophic backtracking; here the worker is stopped and you get a warning instead of a frozen tab. The pattern, flags and text are kept in the link so you can share a test case.

The syntax is JavaScript's (ECMAScript), which supports lookbehind, named groups (?<name>…) and the s and u flags. Other engines such as PCRE, Python or Go mostly agree on the basics but differ on advanced features.

Frequently asked questions

Why does my pattern only find one match?

Add the g flag. Without it, JavaScript stops at the first match.

How do I use named groups?

Write (?<name>…) in the pattern and $<name> in the replacement. Named groups are listed under each match.

Why did it say the pattern took too long?

Nested quantifiers like (a+)+ can backtrack exponentially. Make the inner part unambiguous or use a possessive alternative.

Is this the same as Python or PHP regex?

The basics are, but some features differ. This tester uses the JavaScript engine in your browser.

More Developer tools