Regex Tester & AI Explainer AI
Test patterns live, then get a plain-English explanation from AI.
| # | Match | Capture groups |
|---|---|---|
| 1 | tayloramitverma@gmail.com | $1: tayloramitverma$2: gmail$3: com |
| 2 | hello@example.org | $1: hello$2: example$3: org |
Explain with AI
Get a plain-English, token-by-token breakdown of your pattern.
What is a regular expression?
A regular expression — regex for short — is a small language for describing patterns in text. Rather than searching for one fixed word, you describe the shape of what you are looking for: a phone number, a hex colour, a date, an email address, or the whitespace between words. Regex powers find-and-replace in editors, form validation, log parsing, URL routing, and countless data-cleaning tasks.
The trouble is that regex is famously hard to read. This tester pairs a live, visual matcher with an AI explainer so you can both see what a pattern matches and read a plain-English breakdown of why.
How to use this tester
Enter your pattern in the expression field, toggle the flags you need, then paste sample text below. Every match is highlighted in the preview, the match count updates instantly, and any capture groups appear in the results table. When a pattern gets dense, press Explain this regex for a token-by-token walkthrough with example matches.
Common regex tokens
These are the building blocks you will reach for most often:
| Token | Matches |
|---|---|
| \d | Any digit, 0–9 |
| \w | A word character: letter, digit, or underscore |
| \s | Any whitespace (space, tab, newline) |
| . | Any character except a newline |
| ^ … $ | Start and end of the string (or line, with the m flag) |
| * + ? | Zero-or-more, one-or-more, and optional quantifiers |
| {2,4} | Between 2 and 4 of the preceding token |
| [a-z] | A character class — any lowercase letter |
| (…) | A capture group you can extract later |
| a|b | Alternation — matches a or b |
Handy example patterns
| Goal | Pattern |
|---|---|
| Email address | \b[\w.]+@\w+\.\w+\b |
| Hex colour | #(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b |
| ISO date | \d{4}-\d{2}-\d{2} |
| Slug | ^[a-z0-9]+(?:-[a-z0-9]+)*$ |
| Strip extra spaces | \s{2,} |