AltUtils

Regex Tester

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

CategoryDev Core
Sheet10 / 42
ProcessingIn your browser

Matching…

running… · 127 chars · 3 lines

No matches yet.

What is the Regex Tester?

This regex tester runs your pattern with the browser's own JavaScript RegExp engine, so results match exactly what new RegExp() does in Chrome, Firefox, Safari or Node.js. Matches are highlighted in the test string as you type, and every match is listed with its index, length, numbered capture groups, named groups and — where the engine supports the d flag — the start and end position of each group.

Switch to Replace to preview String.prototype.replace with $1, $<name>, $& (whole match), $` and $' (text before/after the match) and $$ for a literal dollar sign. All eight flags are available: g, i, m, s (dotAll), u (Unicode), v (Unicode sets, with set operations such as [\p{L}--[a-z]]), y (sticky) and d (indices); flags your browser doesn't support are disabled automatically. When you are done, copy the pattern as a ready-to-paste /…/flags literal or a new RegExp() call with correctly escaped backslashes.

Matching runs in a separate Web Worker with a one-second time limit. A pattern with catastrophic backtracking — for example ^(a+)+$ against a long string of a's followed by a b — can take exponential time; instead of freezing the tab, the tester stops the worker and tells you. Zero-length matches (like ^ or \b with the g flag) are handled the same way matchAll does, and the detail list is capped at 5,000 matches to stay responsive. Your text never leaves your device.

Frequently asked questions

Which regex flavor does this tester use?
JavaScript (ECMAScript) regular expressions, executed by your browser's native engine. Syntax that only exists in PCRE, Python or .NET — such as possessive quantifiers (a++), atomic groups (?>…), \A/\Z anchors or inline (?x) comments — is reported as an error or behaves differently. Lookbehind, named groups and Unicode property escapes are supported in all current browsers.
Why does my regex only find one match?
Without the g (global) flag, exec() and String.prototype.match() return only the first match, and replace() only replaces the first occurrence. Turn on g to find or replace every match. The y (sticky) flag additionally requires each match to start exactly where the previous one ended.
What is catastrophic backtracking?
When a pattern contains nested or overlapping quantifiers, such as (a+)+ or (\w|\d)*, a failing match can make the engine try an exponential number of ways to split the input. A 30-character string can take minutes. Fix it by making alternatives mutually exclusive, removing redundant nesting, or anchoring the pattern; this tester stops runs that exceed one second.
How do I use named capture groups?
Write (?<name>…) to capture, \k<name> to backreference inside the pattern, and $<name> in a replacement string. In code the values are available as match.groups.name. Named groups also keep their number, so $1 still works.
What's the difference between the u and v flags?
Both enable Unicode mode, where . and character classes work on full code points and \p{…} property escapes are allowed. v (unicodeSets, ES2024) adds set difference (--), intersection (&&), nested classes and string properties like \p{RGI_Emoji}, but is stricter about unescaped characters such as ( ) [ ] { } / - | inside classes. They can't be combined.
How do I put this regex into my JavaScript code?
Use “Copy as /…/ literal” to get a literal like /\d+/g where forward slashes are escaped for you. If the pattern comes from a string, use “Copy new RegExp()” — it doubles the backslashes so \d stays \d after the string is parsed.