JavaScript Regex Tester with Live Matches and Groups

Test JavaScript regular expressions live: highlighted matches, numbered and named capture groups, flags and replace preview. Runs in your browser.

Runs in your browser. Nothing is uploaded.

Example

Input:

Pattern (?<user>[\w.]+)@(?<domain>[\w.]+)  flags g  on "mail asif@example.com or info@asifdev.com"

Result:

2 matches: asif@example.com (user=asif, domain=example.com), info@asifdev.com (user=info, domain=asifdev.com)

Same engine as your code

This tester uses your browser's own JavaScript RegExp engine, which is the same engine family Node.js uses (V8 in Chrome and Node). That means the results match what new RegExp(pattern, flags) does in an Angular app or an Express handler, including named groups, lookbehind, Unicode property escapes with the u flag and the v flag where your browser supports it. Testers built for PCRE or Python can disagree on these details.

Every match is highlighted in the text, and the table lists each match with its index and capture groups, numbered and named. The replace box shows the result of String.prototype.replace with your replacement, including $1 and $<name> references.

Flags in one line each

g finds every match instead of the first. i ignores case. m makes ^ and $ match at line breaks. s lets the dot match newlines. u enables full Unicode, so \p{L} and astral characters work. y (sticky) matches only at lastIndex. d adds match indices. Without g, only the first match is shown, exactly as in your code.

A frequent surprise: a RegExp object with the g or y flag remembers lastIndex between calls, so calling re.test() twice on the same string can return true and then false. Create the RegExp inside the function, or reset lastIndex to 0, when you reuse a global pattern for validation in Angular form validators or Express middleware.

Avoiding catastrophic backtracking

Patterns such as (a+)+$ can take exponential time on inputs that almost match. In a Node.js server that blocks the event loop for every request, which is a real denial-of-service risk (ReDoS) when the pattern or input comes from users. This tool runs each test in a separate worker and stops it after one second, so a bad pattern cannot freeze the page, and tells you when that happened. In production, avoid nested quantifiers, cap input length before matching, and validate structured input with a parser or a schema library instead of one giant expression.

Frequently asked questions

Is this regex tester JavaScript-compatible?

Yes. It runs the browser's native RegExp engine, so results match JavaScript and Node.js.

How do I use named groups?

Write (?<name>...) in the pattern; the match table shows each group by name, and $<name> works in the replacement.

Why does my pattern time out?

It probably backtracks catastrophically, usually because of nested quantifiers like (a+)+. Make the quantified parts mutually exclusive or limit the input.

Is my text sent anywhere?

No. Matching runs in a worker in your browser.

Related tools