Home › Text Tools › Regex Tester

Regex Tester

Type a pattern and a test string to see every match, its index and its groups, with a replace preview.

Flags
Enter a pattern.
Matches-

Matches

#IndexMatchNumbered groupsNamed groups

Replace preview

-
The dialect is JavaScript, the regular expression syntax that browsers run. Matching uses your browser's own engine. The pattern runs in a background worker that is stopped after 1 second, so a pattern that hangs shows a timeout message instead of freezing the page. Everything runs in your browser; nothing you type is sent or stored.

How it works

Matches are listed in the order the engine finds them. Each shows its index (the position in the test string, counted in UTF-16 code units, as JavaScript does), the matched text, and its groups. Numbered groups are listed in order. Named groups are listed with their names. A group that did not take part in the match shows as "not matched".

Flags change the search. Without g only the first match is listed. Without i, letter case matters. m changes what ^ and $ mean. s lets . cross a line break. u reads the pattern and text as code points, so an emoji counts as one character.

Empty matches, such as x*, are listed too. After an empty match the search moves forward one character, so it always finishes.

Replace preview shows the test string after replacement, using the same rules as JavaScript's String.prototype.replace. $1 is a numbered group, $<name> is a named group, $& is the whole match and $$ is a single dollar sign. With g every match is replaced; without g only the first.

Limits. At most 1000 matches are listed, but the count and the replace preview cover all of them. A pattern that runs longer than 1 second is stopped and reported as a timeout.