devjar tools
English

Regex Tester

Enter a pattern and text; matches light up as you type.

Flags

Matches


      
#IndexMatchGroups

How to use

  1. Type the pattern without slashes and choose the flags. Without g only the first match is found.
  2. Paste the test text. Matches are highlighted and the table lists each index (from 0), the matched text and the groups.
  3. Fill in “Replace with” to see the replaced text at the bottom. Use $1, $2 or $<name> for groups.

\d+ with the g flag on “Hello World 123 foo@bar.com test456” matches 123 and 456. (\w+)@(\w+)\.com matches foo@bar.com with $1 = foo and $2 = bar, and replacing with “$1 at $2” gives foo at bar.

FAQ

Which regex flavor is this?

JavaScript (ECMAScript) regular expressions as built into your browser: named groups (?<name>…), lookbehind (?<=…) and Unicode properties like \p{L} with the u flag. PCRE-only features such as possessive quantifiers or recursion are not supported.

Can a bad pattern freeze the page?

No. Matching runs in a separate worker and is stopped after one second, so catastrophic patterns like (a+)+$ only show an error.

How are positions counted?

From 0, in UTF-16 code units, exactly like match.index in JavaScript. Characters such as emoji take two units.