Regex Tester

Test regular expressions with real-time match highlighting and groups.

/ /
g
i
m

About this tool

Test regular expressions against sample text with live match highlighting, capture-group inspection, and a running match count. Toggle the g, i, and m flags and watch matches update as you edit either the pattern or the text.

It uses your browser's native JavaScript regex engine, so behavior is exactly what you'll get in JavaScript code — and very close to most other languages for everyday patterns.

When to use it

Worked example

To pull dates out of a log line, test the pattern (\d{4})-(\d{2})-(\d{2}) against Deployed 2026-07-05, rollback ready since 2026-06-19 with the g flag on. Both dates highlight, the match count reads 2, and the group panel shows captures 1–3 as year, month, and day. Turn g off and only the first date matches — the most common "why is it only finding one?" answer.

Frequently asked questions

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

g (global) finds all matches instead of stopping at the first. i (ignore case) makes letters match either case. m (multiline) changes ^ and $ to match at each line's start and end rather than only the whole string's.

Why does my dot not match line breaks?

By design, . matches any character except newlines. Use the s flag where supported, or the pattern [\s\S] to genuinely match anything including newlines.

Why is my match longer than I expected?

Quantifiers are greedy by default — .* grabs as much as possible. Add a ? to make it lazy (.*?), or better, use a negated character class like [^"]* when matching up to a delimiter; it's faster and harder to get wrong.

Will patterns tested here work in Python or other languages?

The core syntax — character classes, quantifiers, groups, anchors, alternation — is portable. Differences appear at the edges: lookbehind support, named-group syntax, and flag spellings vary slightly between engines.