Regex Tester & Debugger
Test and debug regular expressions with real-time match highlighting
Pattern
/
/
Test String
Matches
0
No matches yet
Replace
What are Regular Expressions?
Regular expressions (regex or regexp) are sequences of characters that define a search pattern. They are used in virtually every programming language for pattern matching, text search, validation, and string manipulation.
This online regex tester lets you write patterns and instantly see matches highlighted in your test text, with detailed information about match groups and indices.
Common Regex Patterns
| Pattern | Description | Example Match |
|---|---|---|
| \d+ | One or more digits | 42, 2025 |
| \w+@\w+\.\w+ | Simple email pattern | user@mail.com |
| ^https?:// | URL protocol prefix | https:// |
| [A-Z]{2,} | Two or more uppercase letters | USA, HTML |
Frequently Asked Questions
What does the global (g) flag do?
The
g flag makes the regex search for all matches in the string, not just the first one. Without it, the regex stops after finding the first match.What are capture groups?
Capture groups are portions of a regex enclosed in parentheses
(). They capture the matched text for later use. For example, (\d{4})-(\d{2}) captures the year and month separately from a date string.How do I escape special characters?
Characters like
. * + ? ^ $ { } [ ] | ( ) \ have special meaning in regex. To match them literally, precede them with a backslash: \. matches a literal dot.Why is my regex slow on certain patterns?
Some patterns cause "catastrophic backtracking" when the regex engine tries exponentially many combinations. Avoid nested quantifiers like
(a+)+. Use atomic groups or possessive quantifiers where supported.