Regex Tester

Test a regular expression and see live matches and groups.

Runs in your browser — nothing is uploaded

/ /
 

Test a pattern against real text

Enter a regular expression, its flags and some sample text, and the tester lists every match with its position and capture groups. It uses your browser's own JavaScript regex engine, so what matches here matches the same way in JavaScript and TypeScript code and in Node.js.

For example, the pattern \b\d{3}-\d{4}\b with the g flag, run against 'Call 555-0134 or 555-0199 before 5pm.', finds two matches: 555-0134 and 555-0199. The word boundaries stop it matching inside longer numbers.

Flags

g finds every match instead of only the first; the tester always searches globally so it can list them all. i ignores case. m makes ^ and $ match at the start and end of each line instead of the whole string. s lets . match newlines. u enables full Unicode matching, including \p{...} property escapes. y is sticky and only matches at the current position.

With flags gim, the pattern ^error: run against three log lines, 'Error: disk full', 'info: ok' and 'ERROR: retrying', matches 'Error:' and 'ERROR:'. It matches both because the i flag ignores case and the m flag lets ^ anchor at each line.

Capture groups

Parentheses capture part of a match. The pattern (\w+)@(\w+)\.com run against 'ada@example.com, grace@navy.com' matches both addresses and captures the user and domain separately: ada and example, then grace and navy. Use (?:...) for a group that should not capture, and (?<name>...) to give a group a name.

How to use

  1. Enter a pattern and flags.
  2. Paste your test string.
  3. Inspect the matches.

FAQ

Which regex flavour does this use?

JavaScript's (ECMAScript). Most syntax is shared with PCRE, Python and Java, but some features differ. For example, possessive quantifiers and some inline modifiers are not supported in JavaScript.

Why does my pattern match nothing?

Check for unescaped special characters (. * + ? ( ) [ ] { } | \ ^ $), missing flags such as i or m, and anchors that only match at the start or end of the whole text.

Is my test text uploaded?

No. Matching runs entirely in your browser.

How do I match a literal dot, plus sign or bracket?

Escape it with a backslash: \. matches a literal dot and \+ a literal plus. To escape every special character in a string at once, use the Escape Regex tool.

What's the difference between greedy and lazy quantifiers?

Greedy quantifiers (*, +, {n,}) match as much as they can, then back off. Adding ? makes them lazy (*?, +?), so they match as little as possible. Against '<b>bold</b>', <.+> matches the whole string, while <.+?> matches only '<b>'.

Related tools