Regex Tester

Free regex tester with live match highlighting. Test regular expressions against your own text and see every match, group, and index instantly.

/ /
Flags
Highlighted matches
Matches

Worked example

The pattern \d+ with the global flag, run against "abc123def456", finds two matches: "123" and "456" โ€” every run of one or more digits, wherever it occurs in the text.

Frequently asked questions

What does the "g" flag do in a regex?

Without the g (global) flag, a regex stops after finding the first match. With it, matching continues through the whole string, returning every match instead of just the first one โ€” essential for anything beyond a simple yes/no test.

What is a capture group?

Parentheses in a pattern create a capture group, extracting that specific part of a match separately from the full match. The pattern (\d{4})-(\d{2})-(\d{2}) matched against a date like 2026-09-21 captures the year, month, and day as three separate groups, not just confirming the whole string matched.

Why does my pattern match more (or less) than I expect?

The most common cause is a quantifier being greedy by default โ€” .* will grab as much as it possibly can, not the shortest possible match. Adding a ? after a quantifier (.*?) makes it lazy instead, matching as little as possible. Missing anchors (^ and $) can also let a pattern match a substring you didn't intend.