Regex Tester

Test a regular expression against your text with live match highlighting

/ /

Type a regular expression and some test text, and this tool highlights every match live, counts them, and lists any capture groups. Add flags like g, i, or m in the small box. If your pattern is invalid, you'll see exactly why.

What is a regular expression?

A regular expression (regex) is a small pattern language for describing text. Instead of searching for one fixed string, you describe a shape — "three digits, a dash, then four digits" — and the engine finds every piece of text that fits. A few building blocks cover most needs:

Flags change how matching works: g finds all matches (not just the first), i is case-insensitive, m makes ^/$ match each line, and s lets . match newlines.

When and why you'd use it

Worked examples

Pattern \d{3}-\d{4} on "Call 555-1234 or 555-5678" → two matches: 555-1234 and 555-5678 (with the g flag).
Pattern (\w+)@(\w+) on "ada@buzzard" captures group 1 = ada, group 2 = buzzard.
Pattern colou?r matches both color and colour — the ? makes the u optional.

Frequently asked questions

What do the flags mean?

g = global (all matches), i = ignore case, m = multiline (^/$ per line), s = dotall (. matches newlines), u = unicode, y = sticky. This tester uses g internally so it can highlight every match.

What's the difference between greedy and lazy?

By default quantifiers are greedy.* grabs as much as possible. Adding ? makes them lazy.*? grabs as little as possible. This matters a lot when matching between delimiters.

Why isn't my pattern matching?

Common causes: a special character used literally without escaping (e.g. . or ( need a backslash), the wrong flags (missing i for case), or anchors ^/$ that don't fit your text. The status line shows syntax errors.

Is my text sent anywhere?

No — matching runs entirely in your browser with JavaScript's native regex engine. Nothing is uploaded.

Regex flavors differ. This uses JavaScript's engine, which varies slightly from PCRE, Python, or Java (e.g. lookbehind and named-group syntax). Also beware "catastrophic backtracking" — certain nested-quantifier patterns can hang on long input — and don't try to fully parse HTML with regex.