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
- Type your pattern in the pattern field (without the / delimiters).
- Tick the flags you need (g, i, m…).
- 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 <b>bold</b> and <i>it</i>, <.+> 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.