Skip to tool content
Toolioz logoToolioz
Pattern Matching

Regular Expression Tester

A JavaScript regular expression is tested against sample text. Parentheses become capture groups, and $1 and $2 insert those groups into a replacement.

//

Test String Input

0 matches

How does a regex replacement use captured groups?

Parentheses store part of a match as $1, $2, and so on. The replacement string writes those groups into the result, which is how a pattern can rearrange text instead of only finding it.

Why does the exported loop advance lastIndex?

A global RegExp.exec loop must move lastIndex after every match. The generated snippet does that, which avoids the empty-match loop a hand-written exec loop can hit.

Publisher notes · reviewed 10 September 2026

JavaScript regular expressions are not "all regex"

This tester runs the pattern in the browser JavaScript regular-expression engine. A pattern that works in PCRE, Python, or grep may fail here, and the reverse is also true.

Flags and catastrophic backtracking

Flags such as `i`, `g`, `m`, `s`, and `u` change matching. `g` finds every match. Without it you see the first. Nested quantifiers on ambiguous input can lock the tab. That is catastrophic backtracking, not a freeze in Toolioz UI. Simplify the pattern or test a shorter string.

Anchors `^` and `$` mean start and end of string, or of lines when `m` is set. If a pattern "works on regex101 in PCRE" and fails here, switch regex101 flavor to ECMAScript before assuming the tester is broken.

Worked examples

  • Email-shaped text

    A simple `^[^\s@]+@[^\s@]+\.[^\s@]+$` rejects spaces. It still accepts many strings that are not deliverable mailboxes. Do not use it as a deliverability check.

Limits of this page

  • No lookbehind on engines that lack it; modern Chromium has it, older browsers may not.
  • Not a full lexer or parser for HTML or nested CSV.

Sources