.*

Regex Tester

Test regular expressions live with highlighted matches and group capture viewer.

//g

About the Regex Tester

This regex tester highlights every match in your sample text as you type the pattern, and lists the capture groups for each one. Seeing matches appear and disappear while you edit is what makes a pattern quick to get right.

A regex tester replaces the alternative, which is editing a pattern in code and re-running until it works. Highlighting matches live means you see the effect of every character you add, and the moment a change breaks something.

Capture groups are the other half. A pattern that matches is only useful if the right parts are captured, and listing group contents per match shows immediately whether a group grabbed what you intended or swallowed too much.

Greediness causes most surprises. By default a quantifier takes as much as it can, so `.*` between two markers runs to the last one rather than the first. Adding a question mark makes it lazy — visible instantly here as the highlight shrinks.

How to use the Regex Tester

  1. Enter your pattern. Type the regular expression, with flags as needed.
  2. Paste sample text. Provide text that includes both cases that should match and cases that should not.
  3. Watch the highlights. Matches highlight live as you edit the pattern.
  4. Check the groups. Confirm each capture group holds what you expected.

Regex Tester features

  • Every match highlighted in the sample text as you type
  • Capture groups listed per match
  • Editable flags
  • Templates for email, URL, IPv4, dates, hex colours, phone numbers, digits and words
  • Invalid patterns reported rather than failing silently
  • Runs in your browser; nothing is uploaded

Frequently asked questions

Why test a pattern rather than just writing it?

Because regex fails quietly. A pattern that matches too much looks identical to one that works until it runs on real data. Watching matches appear and disappear as you edit is far quicker than debugging afterwards.

What do the flags do?

g finds every match rather than stopping at the first, i ignores case, m makes the anchors match at each line rather than the whole string, and s lets a dot match newlines. Forgetting g is the most common reason only one match appears.

What are capture groups for?

Extracting parts of a match rather than the whole thing. Bracket the section you want and it becomes group 1, available as $1 in a replacement — which is how you reformat rather than merely find.

Why is my pattern so slow?

Usually nested quantifiers on overlapping alternatives, which make the engine backtrack exponentially. If a pattern hangs on a long string, that is the cause — simplify it rather than waiting.

Should I use regex to parse HTML or email addresses?

No for HTML — use a parser, because nesting is beyond what regex can describe. For email, a simple pattern is fine as a sanity check, but the only real validation is sending a message to the address.