NNavShelf

Tools / Regex Tester

Regex Tester

Paste a pattern and some text: every match is highlighted here and listed with its position and capture groups.

Flags
—

Patterns run against your text in the browser and follow JavaScript RegExp rules, including the selected flags.

What is a regular expression?

A regular expression is a pattern that describes a set of strings. It is the fastest way to find, validate or extract structured fragments in a log, a CSV export or a configuration file.

How to use this tool

  1. Type your pattern at the top.
  2. Enable the flags you need — g for all matches, i to ignore case, m and s for multiline and dotall.
  3. Paste the text to test in the box below.
  4. Read the match table to see positions and captured groups.

FAQ

Which flavours are supported?

The JavaScript RegExp flavour — the same syntax that runs in a browser console, Node.js and most modern editors. Lookbehind and named groups are supported in current browsers.

Why does my pattern fail with an invalid error?

The engine reports unbalanced parentheses, unclosed character classes, invalid quantifiers such as a{2,1}, and stray backslashes. The message names the position where parsing stopped.

What does the g flag change?

With g the tool keeps looking and returns every match. Without it the search stops after the first one, which is what JavaScript does when you call test() or exec() once.

How do I match a literal dot or star?

Escape it with a backslash: \. matches a literal dot and \* matches a literal asterisk, because . and * are metacharacters.