Regex Tester
Write a regex pattern and test it against your text in real time. Shows all matches, capture groups, and highlights what matched. Supports all JS regex flags (g, i, m, s, u, y) and gives an error message if the pattern is invalid.
How to use
- Type your regex pattern in the pattern box. Add any flags (g, i, m, etc.) you need.
- Paste or type the test text you want to run it against.
- Matches highlight in real time. Scroll down to see each match and any capture groups.
Related tools:
Regular expressions are powerful for text matching and manipulation but have a steep learning curve. A regex that looks like /^\d{3}-\d{4}$/ checks for a phone number format. Getting the pattern right without testing it leads to bugs that surface unexpectedly in production with real data. Testing against real examples is essential.
The tester runs your regex against your test string and highlights all matches. It shows capture groups separately, which is useful when you are using regex to extract specific parts of a string. Supports JavaScript regex flags: g (global - find all matches), i (case-insensitive), m (multiline), s (dot matches newline).
Frequently Asked Questions
What are the most common regex mistakes?
Forgetting to escape special characters (. matches any character, not just a literal dot - use \. for a literal dot). Using greedy vs lazy quantifiers incorrectly (.* vs .*?). Not anchoring patterns with ^ and $ when you need an exact match. Forgetting the g flag when you expect multiple matches.
Are regex patterns the same across all programming languages?
The core syntax is similar but not identical. JavaScript, Python, Java, and Go all have slight differences in syntax and feature support. This tester uses JavaScript regex. A pattern that works here should work in Node.js and browser JavaScript, but may need minor adjustment for Python (re module) or Java.
How do I match a literal dot or parenthesis?
Escape it with a backslash: \. for a literal dot, \( and \) for literal parentheses. Without escaping, . matches any character and parentheses create a capture group.