🔧 Developer Tools

Regex Tester

Test regular expressions live with colour-coded match highlighting, capture group extraction, replacement preview and plain-English explanations. Includes a 30+ pattern library for email, URL, date, phone and more.

Live match highlighting Capture group extraction Plain-English explanation 30+ pattern library
AdSense — 728×90 Leaderboard

Regex Tester

/
/
TEST STRING 0 matches
Replace
Result
Enter a pattern and test string to see matches
Matches: 0 Groups: 0 Chars: 0 Flags: g
AdSense — 728×90 Leaderboard
🧹
Need to format or minify JSON extracted by your regex?
Run matched JSON strings through the free JSON Formatter to beautify, validate and inspect the structure.
JSON Formatter →
⭐ Ratings

Rate this tool

4.9
★★★★★
Based on 36,217 ratings
5
33,320
4
1,811
3
724
2
362
1
0
Did this regex tester help you debug your pattern?
Thank you for the feedback!
Features

Live highlighting, plain-English explanations and a 30+ pattern library

Most regex testers show a match or no match and stop there. This tester highlights every match in colour directly in the test text, extracts all capture groups individually, previews replacement strings live, explains your pattern in plain English and includes a library of 30+ production-ready common patterns.

Live colour-coded highlighting
Each match is highlighted directly in the test text as you type. Multiple matches use different colours so overlapping or adjacent matches are easy to distinguish.
Capture group extraction
Every match expands to show each capture group individually, numbered and labelled. Named groups ((?P<name>)) display their name. Essential for debugging complex extraction patterns.
Replacement preview
Enter a replacement string using $1, $2 back-references. The live preview shows the full string after replacement, updating with every keystroke in the pattern, test or replace fields.
Plain-English explanation
The Explain tab breaks down your pattern token by token: what each character class, quantifier, anchor and group does. Unique to this tool among free regex testers.
30+ pattern library
Click to load any pattern from the Library tab: email, URL, phone (international), IPv4/IPv6, date formats, postal codes, credit cards, hex colour, JWT, UUID and more.
All five JS regex flags
Toggle global (g), case-insensitive (i), multiline (m), dotAll (s) and unicode (u) flags. Each flag button shows a tooltip explaining what it does. Flags update results instantly.
How to use

How to test a regular expression

1
Enter your pattern
Type or paste your regex pattern in the pattern field (between the two slash delimiters). Toggle flags using the letter buttons to the right. The g flag (global) is on by default to find all matches.
2
Enter test text
Paste the text you want to match against in the lower panel. Matches highlight in colour immediately. The match count badge updates in real time. Invalid patterns show an error in red.
3
Inspect matches and groups
The Matches tab lists every match with its position and all capture groups. Click the Explain tab to see a token-by-token breakdown of your pattern. Use the Library tab to load a pre-built pattern as a starting point.
4
Test replacement strings
Enter a replacement string in the Replace field using $1, $2, $3 to reference capture groups. The preview panel shows the full result of applying the replacement to the test string.
Quick reference

Regex syntax cheat sheet

TokenMatches
.Any character except newline (use s flag to include newline)
\dAny digit 0-9. \D = non-digit
\wWord character [a-zA-Z0-9_]. \W = non-word
\sWhitespace (space, tab, newline). \S = non-whitespace
[abc]Character class: a, b or c
[^abc]Negated class: any character except a, b, c
[a-z]Range: any lowercase letter
^Start of string (or line with m flag)
$End of string (or line with m flag)
\bWord boundary. \B = non-word boundary
TokenMeaning
*0 or more (greedy). *? = lazy
+1 or more (greedy). +? = lazy
?0 or 1 (optional)
{n}Exactly n times
{n,m}Between n and m times
(abc)Capture group 1
(?:abc)Non-capturing group
(?<name>abc)Named capture group
a|bAlternation: a or b
\1Back-reference to group 1
Comparison

LazyTools vs other online regex testers

Feature ⭐ LazyTools regex101.comregexr.comregexpal.com
Live match highlighting
Capture group extraction
Replacement preview
Plain-English explanation✔ (complex)Partial
Common pattern library✔ 30+ patternsCommunityLimited
No login required
No ads⚠ Ads⚠ Ads⚠ Ads
Clean focused UIComplexModerate
Complete guide

Regex Tester — Complete Guide to Testing Regular Expressions Online

A regular expression (regex or regexp) is a sequence of characters that defines a search pattern. Regex is supported in virtually every programming language — JavaScript, Python, PHP, Ruby, Java, Go, Rust, Swift, Kotlin, C# — and is a fundamental tool for text processing, validation, parsing, extraction and transformation. An online regex tester lets you iterate on a pattern interactively, seeing matches in real time, without needing to write and run code each time.

Regex tester with explanation online free

Most regex testers show you whether your pattern matches, but do not explain why. The Explain tab in this tester breaks down your pattern token by token in plain English. For example, the pattern \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b with the i flag is explained as: word boundary, one or more word characters from the set [A-Z0-9._%+-], a literal @, one or more domain characters, a literal dot, and two or more letters for the TLD, terminated by a word boundary. This explanation makes it possible to understand and modify patterns you did not write yourself.

Test regular expression with match highlighting

The core feature of a regex tester is showing you which parts of your test string were matched. This tester highlights each match directly in the test text using a different background colour for each consecutive match. When the global (g) flag is on, all matches are highlighted simultaneously. When g is off, only the first match is highlighted. The highlighting layer is synchronised pixel-perfect with the text input so matched text appears highlighted exactly where it sits in the string.

Regex tester with capture groups online

Capture groups — created with parentheses in a regex — extract substrings from within a match. Group 1 is the first pair of parentheses, group 2 the second and so on. Named groups (?<year>\d{4}) give a group a reusable name. The Matches panel in this tester lists every match with its position in the string, then shows each capture group below it. If a group did not participate in the match (it was in an optional branch that was not taken), it shows as undefined. This panel makes it easy to verify that your extraction groups are capturing exactly the substrings you intend.

Common regex patterns library

The Library tab includes 30+ production-tested regex patterns for the most common use cases: email address validation, HTTP/HTTPS URL matching, international phone numbers, IPv4 and IPv6 addresses, ISO date formats (YYYY-MM-DD), time formats (HH:MM:SS), hex colour codes, credit card number formats, US and UK postal codes, JWT tokens, UUIDs, HTML tags, slug validation, username validation, password strength rules, US Social Security numbers and more. Click Use next to any pattern to load it into the tester.

Regex tester JavaScript Python

This tester uses JavaScript's native RegExp engine, which implements a subset of the Perl-compatible regex (PCRE) syntax used by most modern languages. JavaScript regex is slightly different from Python's re module in a few ways: JavaScript does not support named back-references with \k<name> in older engines, Python uses (?P<name>) for named groups while JavaScript uses (?<name>), and Python's re.VERBOSE (x) flag (which ignores whitespace) is not available in JavaScript. For patterns tested here and used in Python, replace named group syntax (?<name>) with (?P<name>) and the patterns should work identically in Python's re and regex modules.

Frequently asked questions

Greedy quantifiers (*, +, ?) match as much as possible while still allowing the overall pattern to match. Lazy quantifiers (*?, +?, ??) match as little as possible. For example, given the string <b>bold</b>, the pattern <.+> (greedy) matches the entire string <b>bold</b> because it grabs as many characters as possible. The pattern <.+?> (lazy) matches just <b> because it stops at the earliest possible >. In HTML parsing, lazy quantifiers prevent over-matching across tags. Use greedy when you want the longest possible match and lazy when you want the shortest.
Without the global flag, a regex finds only the first match and stops. With g, it finds all matches from left to right through the entire string. In JavaScript, string.match(regex) with the g flag returns an array of all matched strings. Without g, it returns a single match object with capture groups. The g flag is what makes regex useful for replacing all occurrences of a pattern or extracting all instances of a repeated structure. Most regex testers (including this one) default to g being on because showing all matches is more informative for testing.
A named capture group uses the syntax (?<name>pattern) to give a group a descriptive name rather than just a number. For example, (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) extracts year, month and day as named properties. In JavaScript, you can access them via match.groups.year, match.groups.month, match.groups.day. Named groups make complex extraction patterns much more readable and maintainable. In replacement strings, you can reference named groups using $<name> in JavaScript. Named groups are supported in JavaScript (ES2018+), Python, PHP, .NET, Ruby and most modern regex engines.
A non-capturing group (?:pattern) groups part of a regex for quantifiers or alternation without creating a capture group. It behaves like parentheses for grouping but does not consume a capture group number. Use it when you need to group elements (e.g., (?:https?|ftp):\/\/ to match http, https or ftp) but do not need to extract that particular substring. Using non-capturing groups where you do not need the captured value makes your regex more efficient and keeps capture group numbers smaller and easier to work with.
Catastrophic backtracking (also called ReDoS - Regular Expression Denial of Service) occurs when a regex engine has to try an exponential number of combinations to determine that a string does not match. It is most commonly caused by nested quantifiers like (a+)+ or (a|a)+. For example, the pattern (a+)+ against the string aaaaaX causes exponential backtracking as the engine tries every way to assign the characters to the inner and outer groups before concluding there is no match. To avoid it: do not nest quantifiers, use possessive quantifiers or atomic groups (where available), and test with long non-matching inputs as well as matching ones.
In regex, the following characters have special meaning: . * + ? ^ $ { } [ ] | ( ) \. To match any of them literally, prefix with a backslash: \. matches a literal dot, \* matches a literal asterisk, \( matches a literal opening parenthesis. Inside a character class [ ], most special characters lose their meaning: [.] matches a literal dot, [+] matches a literal plus. The exceptions inside a character class are ] (closes the class), \ (escape), ^ (negation at the start) and - (range when between characters). A common mistake is writing .com to match .com when it actually matches any character followed by com. The correct form is \.com.
Without the multiline flag, ^ matches only the very start of the entire string and $ matches only the very end. With the m flag, ^ matches the start of each line (after a newline) and $ matches the end of each line (before a newline). This is essential when processing multi-line text and wanting to match at the beginning or end of each line. For example, the pattern ^ERROR with m will match the word ERROR at the start of any line in a log file, not only if the entire string starts with ERROR. Use m whenever your test text spans multiple lines and your pattern uses ^ or $.
In JavaScript replacement strings, $1 refers to the first capture group, $2 to the second and so on. $& refers to the entire match. $` (backtick) is the string before the match, $' (single quote) is the string after the match. For named groups, use $<name>. For example, to reformat a date from YYYY-MM-DD to DD/MM/YYYY, the pattern (\d{4})-(\d{2})-(\d{2}) with replacement $3/$2/$1 swaps the groups. To insert a literal $, use $$. This tool previews the replacement result in real time so you can verify your back-reference syntax before using it in code.
Related tools

More free developer tools