Regex Tester

Test regular expressions with live match highlighting.

About this tool

Write a JavaScript regular expression, toggle flags and see every match highlighted as you type, together with capture groups and a replace preview.

How to use it

  1. Type a regular expression in the pattern field, without the surrounding slashes.
  2. Toggle flags: g for all matches, i to ignore case, m for multiline anchors, s so . matches line breaks, u for Unicode.
  3. Paste test text and see every match highlighted, with capture groups listed below.
  4. Turn on Replace to preview a substitution using $1, $2 or $<name>.

Questions

Which regex flavour is this?
JavaScript (ECMAScript). It is very close to PCRE and Python for everyday patterns, but lookbehind support, named group syntax and some escapes differ between languages.
How do I match a literal dot or bracket?
Escape it with a backslash: \. matches a dot, \( a parenthesis, \[ a bracket. Inside a character class like [.] most characters lose their special meaning.
What is the difference between .* and .*?
.* is greedy and matches as much as possible; .*? is lazy and matches as little as possible. Lazy matching is what you usually want when extracting text between two markers.
How do named groups work?
Write (?<name>...) to capture into a named group. Its value is shown in the match details and you can use it in a replacement as $<name>.

Something not working, or a result looks wrong? Report a problem with this tool