Test regex patterns against real text, live
A regular expression is only as good as its test data. This tester runs your pattern against text you paste in and shows every match highlighted in place, with its position and capture groups listed below. Change the pattern or the flags and the results update immediately, so you can iterate on a tricky pattern in seconds instead of switching between your editor and a console.
How to use the regex tester
- Write the pattern without slashes: enter the pattern itself, such as \d+ or [A-Z][a-z]+, and choose flags separately. The tool builds the expression for you.
- Watch the highlights: each match is marked in your sample text, so you can see at a glance whether the pattern grabs too much, too little, or the wrong part entirely.
- Check the groups: if your pattern uses parentheses, every group is listed per match. A group that is empty or holds the wrong slice is the most common regex bug, and it shows up here first.
- Start from a preset: the buttons above load common patterns for email addresses, URLs, phone numbers, dates, hex colors and IP addresses. Use them as-is or edit them to fit your format.
Common regex mistakes this tester catches
- Greedy quantifiers: .* grabs as much as possible. If your match runs past the closing quote or bracket you expected, try the lazy form .*? and watch the highlight shrink to the right span.
- Unescaped dots: a plain dot matches any character, so a pattern meant for a file extension like .pdf also matches Xpdf. Escape it as \.pdf when you mean a literal dot.
- Missing anchors: without ^ and $ a pattern matches anywhere inside the text. That is fine for finding things, but for validation you usually want the whole input to match, which means anchoring both ends.
- Forgetting the global flag: without g, only the first match is found. If your match count looks too low, check that g is on.
Regex flavors and compatibility
This tester uses JavaScript regular expressions, the flavor built into every browser and into Node.js. Most everyday patterns work identically in Python, PHP, Java and other languages, but a few features differ: lookbehind, named groups and Unicode property escapes are supported in modern JavaScript, while some older or stricter flavors handle them differently. If a pattern must run in another language, test the final version in that language too, and keep an eye on the error message here: it is the same message JavaScript itself reports, so it tells you exactly what is wrong and where.