Skip to main content

Regex Tester

Test regular expressions live, highlight matches, with flags and capture groups.

/ /
Flags:
  

A pattern, and every match it finds

Two dates pulled out of a sentence, with their capture groups.

Input
pattern:  \b(\d{4})-(\d{2})-(\d{2})\b
flags:    g
text:     due 2026-07-27, shipped 2026-08-03
Output
match 1  "2026-07-27"   groups: 2026 | 07 | 27
match 2  "2026-08-03"   groups: 2026 | 08 | 03

Drop the g flag and only match 1 comes back. Most "my regex only finds the first one" reports are exactly this, not a problem with the pattern.

Online regex tester

Regular expressions are powerful but easy to get wrong and hard to debug. This regex tester lets you build as you go: enter a pattern and test text, and every match is highlighted in real time with capture groups listed. It turns trial-and-error into something you can see.

How to use

  1. Type your pattern in the pattern field (without the / delimiters).
  2. Tick the flags you need (g, i, m…).
  3. Paste content into the test-text area; matches highlight live and groups are listed below.

Common use cases

  • Validate formats like email, phone or URL patterns.
  • Debug a regex that matches too little or too much.
  • Learn and experiment with regex syntax.

Test with real sample text, and watch out for greedy matches

Before you drop a regex into your code, paste a chunk of real sample text here and test it live to see whether it actually matches what you think it does — it's the single biggest time-saver for avoiding debugging later. A few classic traps to keep in mind. Test the edge cases: empty strings, matches at the very start or end, and input with special characters are exactly what tend to break a pattern. Remember that the dot doesn't match newlines by default, so multi-line text needs a dotall flag or a different approach. Characters like . * + ? ( ) have special meaning, so escape them with a backslash to match them literally. And the sneakiest one — greedy versus lazy: a plain .* reaches as far right as it can and often grabs too much, whereas .*? stops at the shortest match.

Why look at the offsets and not just the count?

Because the offsets are what turn a match count into a diagnosis. \d+ against Order 12, item 345, qty 7. gives 3 match(es), listed as #1"12"@6 #2"345"@15 #3"7"@24 — the third starts at 24, which tells you the final 7 was found before the full stop and therefore that the period is not part of \d. Greedy versus lazy is one measurement too: against &lt;b&gt;bold&lt;/b&gt; and &lt;i&gt;it&lt;/i&gt;, <.+> returns 1 match(es) (it swallows the whole string) while <.+?> returns 4 match(es): #1"<b>"@0 #2"</b>"@7 #3"<i>"@16 #4"</i>"@21. Same characters, same input, one question mark of difference.

Frequently Asked Questions

Which regex flavor is this?

It uses the browser JavaScript RegExp engine, so the syntax matches JS. It is broadly compatible with PCRE, Python and others, though a few advanced features (like lookbehind support) may differ slightly.

Which flags are supported?

The common flags: g (global), i (ignore case), m (multiline), s (dotAll), u (unicode) and y (sticky). Just tick them.

Is my data uploaded?

No. The pattern and test text are matched locally in your browser and never uploaded.

Related reading

Regular Expressions for Beginners: A Practical Cheat Sheet →

Embed this tool

Add this tool to your own website or blog for free — just copy and paste the code below (it includes a link back to this site).