Regex Tester & AI Explainer AI

Test patterns live, then get a plain-English explanation from AI.

//g
Preview2 matches
Reach me at tayloramitverma@gmail.com or hello@example.org — not at "plain text".
#MatchCapture groups
1tayloramitverma@gmail.com$1: tayloramitverma$2: gmail$3: com
2hello@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:

TokenMatches
\dAny digit, 0–9
\wA word character: letter, digit, or underscore
\sAny 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|bAlternation — matches a or b

Handy example patterns

GoalPattern
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,}

Frequently asked questions

What is a regular expression?+
A regular expression (regex) is a compact pattern used to search, match, and manipulate text. Instead of looking for a fixed string, you describe the shape of what you want — for example "one or more digits" or "an email-like token" — and the regex engine finds every piece of text that fits.
How do I test a regex with this tool?+
Type your pattern in the expression box, toggle any flags you need (global, ignore-case, multiline, and so on), then paste sample text in the test area. Matches are highlighted live and each capture group is listed in the results table, so you can see exactly what the pattern captures.
What do the flags g, i, m, and s mean?+
g (global) finds all matches instead of stopping at the first. i makes matching case-insensitive. m (multiline) lets ^ and $ match the start and end of each line. s (dotall) lets the dot match newline characters too. u enables full Unicode handling and y anchors matching to a sticky position.
Does the AI explanation send my data anywhere?+
Only the pattern and its flags are sent to the AI when you click "Explain this regex" — never your test text. The live testing and highlighting run entirely in your browser.
Which regex flavour does this use?+
It uses the JavaScript (ECMAScript) regex engine, the same one that runs in browsers and Node.js. Most syntax is shared across languages, but a few features differ from PCRE, Python, or Java flavours.