Test and debug regular expressions with real-time highlighting and replacement
This regex tester uses JavaScript's built-in RegExp engine, which handles patterns with backtracking (greedy vs. non-greedy quantifiers), lookaheads/lookbehinds, and Unicode support (with the 'u' flag). Matches are highlighted in real-time by running regex.exec() in a loop (for global flag) or regex.test(). Capture groups ($1, $2, etc.) are extracted via regex.exec().groups. Flags change behavior: 'g' finds all matches, 'i' ignores case, 'm' makes ^ and $ match line breaks, 's' makes . match newlines, 'u' enables Unicode mode, 'y' makes sticky matching. Catastrophic backtracking can freeze the browser on complex patterns with nested quantifiers—use atomic groups or possessive quantifiers (not supported in JS) carefully.
Learn more about this tool and related topics in our blog.
Ditch the StackOverflow copy-pasting. Master regular expressions with our interactive guide to patterns, flags, and capture groups.
Privacy isn't a perk, it's a requirement. See why top developers are ditching cloud converters for local-first browser utilities.
"When I first learned regex, I thought it was just random symbols. But then I realized it's actually like a secret code for finding text. I built this tester to help me (and you!) see exactly what's matching in real-time."
Azeem Mustafa
Privacy Architect
Enter your regular expression pattern in the top input box.
Select any flags you need (e.g., 'Global' for multiple matches, 'Case Insensitive' for /i).
Type your test string in the text area below.
Matches will be highlighted instantly using regex.exec() loop.
Hover over matches to see capture group details (groups[0], groups[1], etc.).
Match basic email patterns
Pattern: \w+@\w+\.\w+ Test: hello@example.com
Match! ✅ Matches "hello@example.com"
Find US phone numbers in text
Pattern: \d{3}-\d{3}-\d{4}
Test: Call me at 555-123-4567Match! ✅ Captures "555-123-4567"
Swap first and last name
Pattern: (\w+) (\w+) Replace: $2, $1 Test: John Doe
"Doe, John" - capture groups swapped!
Test your email regex pattern before deploying.
Pull specific info from log files
Extract domain from URLs in text.
Remove unwanted characters from input.
**Characters**: - `.` = Any character (except newline) - `\d` = Any digit (0-9) - `\w` = Word character (a-z, A-Z, 0-9, _) - `\s` = Whitespace (space, tab, newline) **Negations** (uppercase = opposite): - `\D` = Not a digit - `\W` = Not a word character - `\S` = Not whitespace **Quantifiers**: - `*` = 0 or more - `+` = 1 or more - `?` = 0 or 1 (optional) - `{3}` = Exactly 3 - `{2,5}` = Between 2 and 5 - `{3,}` = 3 or more **Anchors**: - `^` = Start of string/line - `$` = End of string/line - `\b` = Word boundary Example: `^\d{3}$` = Exactly 3 digits, nothing else
**Basic Capture**: Use () to capture parts of match Example: `(\w+)@(\w+)` Matches: john@example - Full match: john@example - Group $1: john - Group $2: example **Use in Replace**: Pattern: `(\w+) (\w+)` Replace: `$2, $1` Input: 'John Doe' Output: 'Doe, John' **Non-Capturing Group**: `(?:...)` Groups for logic but doesn't capture: `(?:Mr|Mrs|Ms)\.? (\w+)` Matches title + name but only captures name **Named Groups**: `(?<name>...)` Example: `(?<user>\w+)@(?<domain>\w+)` Access by name instead of number! Capture groups are POWERFUL for extraction and transformation.
**g - Global**: Find ALL matches, not just first - Without: 'aaa'.match(/a/) = ['a'] (first only) - With g: 'aaa'.match(/a/g) = ['a','a','a'] (all) **i - Case Insensitive**: Ignore CAPS - Pattern: `/hello/i` matches Hello, HELLO, hElLo **m - Multiline**: ^ and $ match line boundaries - Without m: ^ = start of string only - With m: ^ = start of each line **s - DotAll** (newer): . matches newlines - Normally . doesn't match \n - With s: .* can match across lines **u - Unicode**: Full Unicode support - Enables matching emoji and special chars properly **y - Sticky**: Advanced, rarely used - Matches must start at lastIndex position Most common: Use /g for find all, /i for case-insensitive, /m for multiline text!
Power up your workflow with related utilities.
Get the full stats on your writing. Words, characters, and even reading time estimations.
Instantly change text between UPPERCASE, lowercase, Title Case, and more.
Write professional READMEs and blog posts with a live side-by-side preview. Supports GitHub Flavored Markdown and one-click PDF export.
Learn more about this tool and related topics in our blog.
Ditch the StackOverflow copy-pasting. Master regular expressions with our interactive guide to patterns, flags, and capture groups.
Privacy isn't a perk, it's a requirement. See why top developers are ditching cloud converters for local-first browser utilities.