Regex tester

Test regex patterns with live match highlighting and groups.

/ /

You have a pattern that works on one example and quietly fails on the next. Rather than re-running a script each time, paste the pattern and a few realistic lines here and watch the matches light up as you type. Toggling a flag shows immediately what it changes, which is usually faster than reasoning about it.

How it works

Pattern, flags, test string

The pattern box sits between the two / delimiters, so type the expression only — (\d{4})-(\d{2})-(\d{2}), not /(\d{4}).../g. The four checkboxes below it are the flags: g (global) finds every match instead of stopping at the first, i (ignore case) makes letters case-insensitive, m (multiline) makes ^ and $ match at each line break, and s (dotall) lets . match a newline. The lower box holds the text you are testing against; it starts with a short sample you can replace.

Reading the result

Matches are highlighted in place, so you can see at a glance whether the pattern caught too much or too little. Each match is also listed with its capture groups — the parts wrapped in parentheses — numbered in the order the opening parentheses appear. That list is the quickest way to check whether group 1 really holds the year and not the whole date. If nothing highlights, the pattern is either wrong or invalid; an invalid pattern is reported rather than silently matching nothing.

A note on flavours

The engine is your browser's JavaScript regex. Most everyday syntax is shared across languages, but lookbehind, named groups and Unicode property escapes differ between JavaScript, PCRE, Python and Go. A pattern verified here should still be checked in the language you will ship it in.

Terms explained

Flag
A switch that changes how the whole pattern is applied — g, i, m and s here — written after the closing delimiter in most languages.
Capture group
A part of the pattern in parentheses whose matched text is extracted separately, numbered from 1 in order of the opening parenthesis.
Global (g)
Keeps searching after the first hit so every occurrence is returned instead of just one.
Multiline (m)
Makes the anchors ^ and $ apply at the start and end of each line rather than the whole string.
Dotall (s)
Lets the dot match newline characters too, which it does not do by default.
Greedy vs lazy
`.*` takes as much as it can; `.*?` takes as little as possible. The difference explains most patterns that match far more than intended.

Frequently asked questions

Do I include the slashes and flags in the pattern box?

No. The `/` delimiters are already shown on either side of the box, and the flags have their own checkboxes. Pasting `/abc/gi` in full will make the slashes part of the pattern and stop it matching.

Why does my pattern only find the first match?

The global flag is off. Without **g**, the search stops at the first hit. Tick g to see every occurrence highlighted.

Is my test data sent to a server?

No. The pattern runs in your browser using its own regex engine, so nothing you type leaves the page. That said, it is still good practice to use sample data rather than real customer records.

Which regex dialect does this use?

JavaScript's. Basic syntax — character classes, quantifiers, anchors, groups — behaves the same nearly everywhere, but advanced features such as lookbehind, named groups and `\p{...}` escapes vary by language, so confirm in your target environment.

My pattern matches far more text than expected. Why?

Almost always greedy quantifiers. `<.*>` swallows everything from the first `<` to the last `>`; `<.*?>` stops at the first closing bracket. Adding `?` after `*` or `+` makes it lazy.