g i m s u y d
Use $1, $2… or $<name> for capture groups and $& for the whole match.

Result

Enter a pattern and some test text.

How to use this tool

  • Enter the pattern without slashes, and flags such as g (global), i (ignore case) or m (multiline).
  • Paste test text. Matches are highlighted and listed with their positions and capture groups.
  • Add a replacement to preview the result — use $1, $<name> or $& for groups and the whole match.

How it works

The pattern runs in your browser’s JavaScript regular expression engine. It runs in a background Web Worker with a time limit, so a pattern with catastrophic backtracking (such as (a+)+ on a long string) is stopped instead of freezing the page. Without the g flag, only the first match is found, exactly as in JavaScript.

Example

Dates

Pattern (?<year>\d{4})-(\d{2}) with flag g on “Dates: 2024-01 and 2025-12” finds 2 matches; the first has year = 2024 and group 2 = 01.

Swapping text

Pattern (\w+)@(\w+) with replacement $2 at $1 turns “me@home” into “home at me”.

Privacy and limitations

  • Patterns and text stay in your browser.
  • JavaScript regular expressions differ from PCRE (PHP), Python and .NET in some features, such as possessive quantifiers and some lookbehind rules.
  • At most 1,000 matches are listed.

Frequently asked questions

Why does my pattern only find one match?

Add the g (global) flag to find every match.

What is catastrophic backtracking?

Some patterns, usually nested quantifiers like (a+)+, can take exponentially long on certain inputs. This tester stops a pattern after about 1.5 seconds.