/ /
Flags g global i case-insensitive m multiline (^ and $ per line) s dotAll (. matches newlines) u unicode
Presets
Test String
Results
Matches 0
Enter a pattern and a test string to see the matches.
Capture Groups 0
Capture groups show here when your pattern has parentheses.
Quick Reference click to insert

What is a regex tester?

A regex tester runs a regular expression against sample text and shows what it matches. You use it to build and debug patterns for form validation, search and replace, and log parsing, before you put the pattern into code. This tester uses the JavaScript regex engine of your browser.

How to test a regex

  1. Type a pattern in the Pattern field, or select one under Presets.
  2. Select the Flags that you need (g, i, m, s, u).
  3. Enter your text in the Test String pane. Matches highlight as you type.
  4. Read each match and its groups under Matches and Capture Groups.
  5. Click a token in the Quick Reference to insert it into the pattern.

Why does my regex match too much?

Quantifiers such as .* and .+ are greedy: they take as much text as they can. On <b>a</b><b>c</b>, the pattern <b>.*</b> matches the whole line. Add ? to make the quantifier lazy (.*?), or use a negated set such as [^<]*.

Frequently Asked Questions

What do the g, i, m, s and u flags do?

g finds every match, not only the first. i ignores case. m makes ^ and $ match at each line. s lets . match line breaks. u turns on full Unicode support, for example for \p{L} and emoji.

Why does my pattern say "invalid regular expression"?

Usually a special character is not escaped, or a group is not closed. Brackets and parentheses must balance. If you copied the pattern from a JavaScript string, change \\d to \d. The status bar shows the error message of the engine.

What are capture groups?

Each part in parentheses is captured on its own. For example, (\d{4})-(\d{2})-(\d{2}) captures the year, month and day. Use (?:…) to group without capture, and (?<name>…) for a named group.

Does this tester support PCRE or Python regex?

It uses the JavaScript (ECMAScript) engine. Most everyday patterns work the same in PCRE and Python. Recursion and conditional groups from PCRE do not work here. Lookbehind works in current browsers.

Is my regex or text sent to a server?

No. The pattern runs in your browser with the built-in RegExp engine.