Regex Tester
Free online regular expression testing tool. Real-time match highlighting, capture group extraction with details, regex replace mode, 50+ common patterns library, and syntax explanation. All processing is done client-side — your data never leaves your browser.
/
/
Test Text
Match Result
🔍 Regex Explanation
📋 Match Details (Capture Groups)
Capture group details will appear here after running a test.
📖 Common Patterns Library
📘 Regex Syntax Reference
| Pattern | Description | Example |
|---|---|---|
. | Matches any single character (except newline) | a.b matches "acb", "a2b" |
\d | Matches a digit (0-9) | \d{3} matches "123" |
\w | Matches a word character (letter, digit, underscore) | \w+ matches "hello" |
\s | Matches whitespace (space, tab, newline) | \s+ matches consecutive whitespace |
\b | Word boundary | \bword\b matches exact word |
^ | Matches start of string/line | ^Hello matches "Hello" at the start |
$ | Matches end of string/line | end$ matches "end" at the end |
* | Matches 0 or more of preceding element | ab*c matches "ac", "abc", "abbc" |
+ | Matches 1 or more of preceding element | ab+c matches "abc", "abbc" |
? | Matches 0 or 1 of preceding element (optional) | colou?r matches "color", "colour" |
{n} | Matches exactly n times | \d{4} matches 4 digits |
{n,} | Matches at least n times | \d{2,} matches 2+ digits |
{n,m} | Matches between n and m times | \d{2,4} matches 2-4 digits |
[abc] | Character set, matches any character in the set | [aeiou] matches any vowel |
[^abc] | Negated character set, matches any character NOT in the set | [^0-9] matches non-digit |
(pattern) | Capture group, extracts matched substring | (\d+) captures digit sequence |
(?:pattern) | Non-capturing group, groups without capturing | (?:\d+) groups but does not capture |
a|b | OR, matches either a or b | cat|dog matches "cat" or "dog" |
(?=...) | Positive lookahead | \d(?=px) digit followed by "px" |
(?!...) | Negative lookahead | \d(?!px) digit NOT followed by "px" |
(?<=...) | Positive lookbehind | (?<=\$)\d+ digits preceded by $ |
(?<!...) | Negative lookbehind | (?<!\$)\d+ digits NOT preceded by $ |
What is a Regular Expression?
A regular expression (regex / regexp) is a sequence of characters that defines a search pattern. It is widely used for text search, validation, replacement, and data extraction. Almost every major programming language (JavaScript, Python, Java, PHP, etc.) supports regular expressions.
Features
- Real-time match highlighting — See all matches highlighted instantly as you type your pattern and test text
- Flag toggles — Supports g (global), i (case-insensitive), m (multiline), s (dotAll), u (Unicode)
- Match details with capture groups — Position, content, and capture groups for each match at a glance
- Replace mode — Enter a replacement template with $1, $& back-references support
- Syntax explanation — Break down your regex pattern into human-readable explanations, token by token
- 50+ common patterns library — Number validation, character validation, text processing, and programming patterns — one-click to apply
- Built-in syntax reference table — Quickly look up common metacharacters and regex rules
Common Use Cases
- Form validation: email, phone number, URL, ID card format verification
- Text search and replace: batch replace text matching specific patterns
- Log analysis: extract IPs, timestamps, and error messages from log files
- Data extraction: extract specific fields from HTML, JSON, and other structured text
- Code refactoring: batch rename variables, reformat code
Tip: Start by selecting a common pattern or typing a regex, then enter test text — results update in real time.