Dev Converters
Regex

Regex Tester

Test JavaScript regular expressions against sample text. Highlights all matches and lists captured groups. Runs in-browser with the native RegExp engine.

How it works

Regular expressions are a miniature language for describing patterns in strings. JavaScript's built-in `RegExp` implements ECMAScript's flavour — similar to Perl but with some differences (no `\G`, limited lookbehind in older engines, no in-regex comments). This tester uses the native engine so results match exactly what your app code will see.

Flags change matching behaviour: `g` enables global matching (find all, not just the first), `i` ignores case, `m` makes `^` and `$` match line boundaries, `s` makes `.` match newlines, `u` enables Unicode mode (essential for emoji and astral plane characters), `y` enables sticky matching. The tester forces `g` so you always see every match; you still control the rest.

For captures, the tester shows both numeric groups (first pair of parentheses is group 1) and named groups (via `(?<name>...)`). Watch out for catastrophic backtracking: patterns like `(a+)+b` can go exponential on certain inputs. If the tester hangs, refresh your browser and simplify the quantifiers — nested `+` and `*` are the usual culprits.

Frequently asked questions

Which regex flavour is used?
The native ECMAScript RegExp engine — the same one as V8, JavaScriptCore, and SpiderMonkey. No PCRE lookbehinds from older days, but modern features like `y`, `u`, and named groups are supported.
How do I use named capture groups?
Write `(?<name>...)` in your pattern. The output lists them by name in addition to numeric index.
What if my regex has catastrophic backtracking?
The browser runs the regex synchronously; a truly pathological pattern may freeze the tab. Refresh and simplify — look for nested quantifiers like `(a+)+b`.

Related tools