Interactive JavaScript Regular Expression Tester
Test and debug complex pattern matching with instant color-coded capture group analysis.
Regular expressions are easy to get nearly right and hard to get exactly right, so a place to watch matches appear is valuable. Typical uses are checking a pattern for pulling email addresses or order numbers out of a log, testing a validation rule before putting it into a form, or working out why a pattern matches too much. Students use it to see how flags change the outcome. Because the match list updates with every keystroke, you can build a pattern gradually and notice the exact moment it starts catching things it should not.
Type your pattern into the field labelled Regular Expression Pattern; the slashes on either side are only decoration, so do not type them. Put flags in the box labelled Flags, where g finds every match, i ignores case, m lets ^ and $ work per line and s lets the dot cross line breaks. Paste your sample into Test String Input. Under Detected Matches you will see a count and each hit numbered, with its text and the index where it starts. A red Regex Error message appears if the pattern is invalid.
This page uses the JavaScript regular expression engine in your browser, so features from other languages, such as possessive quantifiers or some inline flags, may behave differently or be rejected. Matches are listed as whole matches only; capture groups are not broken out, so wrap your test in a different tool if you need group contents. Keep the g flag on, since the list is built from repeated matching, and be careful with patterns that can backtrack badly on long text, as they may make the tab sluggish.
Try the pattern \d{3}-\d{4} with flags g on the text call 555-0199 or 555-0123. The counter shows 2 matches: 555-0199 at index 5 and 555-0123 at index 17. If you remove the g flag, this page reports an error instead of matches, so keep it on. If your pattern matches far more than expected, make it tighter, for example by adding word boundaries with \b or replacing .* with a narrower class. Once the matches look right, copy the pattern into your code and test it there as well.
Key Highlights:
- Real-time match highlighting
- Capture groups table
- Pre-built patterns (Email, URL, IP, Phone, Dates)
- Regex flags control

