Regex Tester / Editor / Match Visualizer

Test, visualize, replace, and explain regular expressions. Everything runs in your browser

⚙ Engine: JavaScript RegExp
Pattern
Flags:
Insert:
Samples:
Test Text 0 chars · 0 lines
Highlighted Matches
Matches: 0
Time:
Engine: JS RegExp
Matches Table
# Match Start End Length Groups
Capture Groups
Replacement syntax: $1 $2 capture groups · $& full match · $` before match · $' after match · $$ literal $ · $<name> named group
Replacement
Source Text
Result
Enter a regex pattern above to see a human-readable explanation.

Click any example to load it into the Test tab and run it automatically.

All regex testing, matching, replacing, and pattern analysis happens in your browser. Your text and patterns are never sent to any server.

Tips

Auto Run for Instant Feedback

With Auto Run enabled, results update as you type. The tool debounces input to keep the UI responsive. For very large texts, Auto Run is automatically disabled to prevent freezing.

Understanding Capture Groups

Parentheses () create capture groups. Click any match in the table to see its groups. Named groups (?<name>...) make regex more readable and replacement easier with $<name>.

Avoiding Catastrophic Backtracking

Nested quantifiers like (a+)+ or (a|a)*b can cause exponential execution time. Keep patterns simple, use atomic constructs when possible, and test with edge-case inputs.

JavaScript Engine Differences

This tool uses JavaScript RegExp. Some features like possessive quantifiers and atomic groups are not available. Lookbehind requires a modern browser. Python, PCRE, and .NET regex may behave differently.

Common Use Cases

📝

Form Validation

Test email, phone, date, and password patterns before implementing them in your frontend or backend validation logic.

📊

Log Analysis

Extract timestamps, error levels, and messages from log files using named capture groups. Copy matches as JSON for further processing.

🔍

Data Extraction

Pull URLs, IP addresses, UUIDs, or hex colors from unstructured text. The match table shows every occurrence with position details.

⚙️

Code Refactoring

Use the Replace tab to test find-and-replace patterns before applying them in your IDE. Supports capture group references like $1 and $<name>.

📚

Learning Regex

The Explain tab breaks down any pattern into plain-English tokens. Combined with the Cheat Sheet and Examples, it is a complete learning environment.

Frequently Asked Questions

What is a regular expression?
A regular expression (regex) is a pattern that describes a set of strings. It is used for searching, matching, and manipulating text. For example, \d+ matches one or more digits.
Is this tool using JavaScript regex?
Yes. This tool uses the built-in JavaScript RegExp engine. Some syntax may differ from PCRE (PHP), Python re, .NET, or Java regex. The engine label is always shown.
Why does my regex work here but not in Python?
JavaScript and Python regex engines differ in some areas. For example, lookbehind in JS must be fixed-length in some browsers, \b behavior with Unicode differs, and possessive quantifiers are not available in JS.
What does the global (g) flag do?
Without the global flag, only the first match is returned. With g enabled, all non-overlapping matches in the entire text are found and listed.
Why is only one match shown?
The global (g) flag is probably not enabled. Click the g button in the flags row to enable it and find all matches.
What are capture groups?
Parentheses () in a regex create capture groups that remember the matched text. Group 1 is the first set of parentheses, Group 2 is the second, etc. Named groups use (?<name>...) syntax.
How do replacements like $1 work?
In the replacement string, $1 refers to the text matched by the first capture group, $2 to the second, and so on. $& is the entire match. $<name> refers to a named group.
Does this tool upload my data?
No. All regex testing, matching, and replacing happens entirely in your browser using JavaScript. Your text and patterns never leave your device.
Why is my pattern slow?
Some patterns cause catastrophic backtracking — exponential execution time on certain inputs. Avoid nested quantifiers like (a+)+, use specific character classes instead of .*, and test with large inputs carefully.
What is catastrophic backtracking?
When a regex engine tries many permutations to find a match and fails, execution time can grow exponentially. This typically happens with ambiguous patterns like (a+)+b on input "aaaaaaaac".
Can I test named groups?
Yes. Use (?<name>...) syntax in your pattern. Named groups appear in the Capture Groups panel and can be referenced in replacements with $<name>.
Does this tool support lookbehind?
Yes, in modern browsers. Lookbehind (?<=...) and (?<!...) are supported in Chrome 62+, Firefox 78+, and Safari 16.4+. Older browsers may throw an error.