Regex Tester & Explainer: Live Matches, Groups, Code
Test JavaScript regular expressions live: highlighted matches, capture groups, a plain-English explanation of each token, and code in JS, Python and PHP.
Updated November 2026
Reviewed by Rafael Duarte
const regex = /your-pattern/g;
const str = `Contact support at help@blueprint-precision.com or send queries to admin@system.internal.
Please rea`;
let m;
while ((m = regex.exec(str)) !== null) {
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m` variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}Enter a pattern above to see it explained token by token.
How to use this regex tester
JavaScript regex engine, results update as you type
1. Type your pattern
Enter it in Regular Expression, without the surrounding slashes. The Regex Explanation panel describes each token in plain English as you type, or pick a ready-made pattern from the Pattern Library.
2. Set flags and paste your test string
Toggle Global, Case insensitive, Multiline and Dot all (g, i, m, s). Matches are highlighted under Live Results, with the match count and each match's capture groups listed below.
3. Take it to your code
Copy Pattern gives you /pattern/flags. The Code Generator has JavaScript, Python and PHP tabs with a snippet to start from; check it before use, since the test string is cut to 100 characters.
What this regular expression tester does
More than just highlighting matches
Plain-English explanation
The Regex Explanation panel lists the first 16 tokens of your pattern (classes, groups, lookarounds, quantifiers, anchors, escapes) with what each one does, and marks lazy quantifiers.
Capture groups per match
Each match is listed with its position and its groups numbered #1, #2 and so on. Named groups such as (?<year>...) work, but they're shown by number, not by name.
Code in JavaScript, Python and PHP
A starting snippet with your pattern, flags and the first 100 characters of your test string. The JavaScript version doesn't escape / inside the pattern, and the Python one keeps JavaScript group syntax and always uses re.findall.
Pattern Library
Seven starting points with sample text: Email Address, URL (Web), IPv4 Address, Phone Number, Date (YYYY-MM-DD), Hex Color and Brazilian CNPJ. They're deliberately simple: the email pattern allows 2 to 4 letter domain endings and the phone pattern follows North American formats.
Examples
See how common patterns behave against real text
\d+ against "Order 1234 on 2024-01-15"^(\d{4})-(\d{2})-(\d{2})$<.+> (greedy) against <b>bold</b><.+?> (lazy) against <b>bold</b>When you'll reach for a regex tester
The most common scenarios developers use it for
Validating email or phone input
Run the pattern against real edge cases before shipping it to a production form.
Parsing log files
Pull out timestamps, IP addresses, or error codes using anchors and character classes without writing a script first.
Checking what a cleanup regex will hit
Before running replace() with a negated class like [^a-z0-9-], paste sample input and see exactly which characters it catches. This page only finds matches; the replacing happens in your code.
Extracting dates, IDs and codes
Pull order numbers, ISO dates or hex colors out of a block of text and confirm the capture groups hold the parts you need.
Common regex mistakes
Forgetting to escape special characters
A bare . matches any character. To match a literal period, escape it as \.
Forgetting the g flag
Without it, only the first match is returned. Leave Global on whenever you need every match.
Expecting \w to match accented letters
In JavaScript without the u flag, \w only covers [a-zA-Z0-9_], so café matches as caf. This tester doesn't offer the u flag, so Unicode classes like \p{L} won't work here either.
Catastrophic backtracking
Nested quantifiers like (a+)+ against a long non-matching string can make the engine run for a very long time. This tester runs on the page itself with no timeout, so such a pattern can freeze the tab.
Why use this regex tester
Instead of sprinkling console.log through your code and re-running it every time you tweak the pattern, you iterate on the regex here and paste it into the project once it matches what you expect. It uses your browser's own JavaScript engine, so what matches here matches in JavaScript.
The plain-English explanation and the Pattern Library help while you're still learning the syntax; the live highlighting and numbered groups are quick enough for checking a pattern before you commit it. For five patterns worth knowing by heart, see Five Regular Expressions Worth Memorizing.
Greedy vs. lazy quantifiers
The most common reason a match is bigger than expected
<b>x</b><.+> grabs the whole string<.+?> grabs each tagFrequently asked questions
A regex tester lets you write a regular expression and instantly see which parts of a test string it matches, with visual highlighting and a breakdown of any captured groups. It replaces the trial-and-error of running your regex through actual code just to check whether it works.
It runs your pattern with JavaScript's RegExp (ECMAScript), the engine built into your browser. Four flags are available and can be combined: g (Global, every match instead of the first), i (Case insensitive), m (Multiline, ^ and $ match at line breaks) and s (Dot all, . also matches newlines). The u, y and d flags aren't offered.
No. It finds and highlights matches and shows their capture groups, but it has no replacement field. Test the pattern here, then do the replacement in your code with str.replace(regex, '$1') or the equivalent in your language.
Greedy quantifiers like .* or .+ consume as much text as possible before backing off to satisfy the rest of the pattern. Switch to the lazy version — .*? or .+? — to match the shortest possible string instead.
Any part of the pattern wrapped in parentheses ( ) becomes a capture group. Group 1 is the first (...), group 2 is the second, and so on; (?:...) groups without capturing. Named groups like (?<year>\d{4}) let you read the value by name in code, though this tester lists them by number.
Engines differ in syntax even when the pattern looks the same. Python writes named groups as (?P<name>...) while JavaScript uses (?<name>...), and some features exist in only one of them. This page tests the JavaScript flavor, and its Python snippet copies the pattern as is, so rename groups to (?P<name>...) and run it once in Python before shipping.
Treat it as a starting point. The test string is cut to the first 100 characters. In JavaScript, a / inside your pattern has to be escaped as \/ by hand (the PHP snippet already does it). The Python snippet always calls re.findall, which returns the groups instead of the full match when the pattern has capture groups.
This tester runs entirely in your browser. Your pattern and test string are never sent to a server, so you can test against sensitive data like real emails, tokens or log lines.
References
Related Tools
- Base64 Decode Online — Free Base64 to Text Decoder Developer Free online Base64 decoder — decode Base64 strings back to plain text instantly in your browser. Validates input and shows decoded payload size.
- Base64 Encoder: Encode Text, PDF & Files Online Developer Encode UTF-8 text or any file (PDF, DOCX, XLSX, ZIP up to 50 MB) to Base64 or Base64URL. Runs in your browser, nothing is uploaded. Free, no sign-up.
- Base64 to Image Online: Preview and Save PNG, JPG, GIF Developer Paste raw Base64 or a data:image URL to preview the image with its type, dimensions and size, then save the original file. No upload, runs in your browser.
- Chmod Calculator: Linux Permissions 755, 644 & 777 Developer Tick read, write and execute or type 755 to get rwxr-xr-x, a ready chmod command and a warning for 777. Includes umask, SUID, SGID and sticky bit.
- CSV to JSON Converter & JSON to CSV Online Developer Paste or upload a CSV (comma, semicolon, tab or pipe) and get clean JSON. Also converts JSON to CSV that Excel opens without garbled characters.