Regex Tester
Test regular expressions with live matching
What is a Regex Tester?
Tests a JavaScript regular expression against sample text and reports whether it matches, how many matches exist and what the matched substrings are. Because it runs on the browser's own RegExp engine, a pattern that passes here behaves identically in your JavaScript or TypeScript code. Use it to prototype validation patterns (emails, IPs, hostnames), debug why a pattern over- or under-matches, and learn flag behavior, all without a console or build step.
How to Use This Tool
- Type the Pattern, Enter JavaScript regex syntax without slashes, e.g. [a-zA-Z]+ or ^192\.168\.\d+\.\d+$.
- Type the Flags, Add letters like i (case-insensitive), m (multiline) or s (dot-all) in the Flags box; leave it empty for a plain single match.
- Enter the Test String, Paste the sample text to match against in the multi-line box.
- Click Test, Valid Regex, Has Match, Total Matches and the matched substrings appear instantly.
Understanding the Results
Valid Regex confirms the pattern compiled; otherwise an Error row shows the JavaScript engine's own message (e.g. Invalid flags, Unterminated group). Has Match answers whether the pattern matched at all, Total Matches counts every match found with global matching applied internally, and Matches lists the matched substrings comma-separated (shown only when the count is above zero).
Tips & Best Practices
• Do not type g in the Flags box: the tool already applies global matching internally when counting, and a duplicate g flag makes the pattern invalid, add only i, m, s, u or y as needed.
• Anchor validation patterns with ^ and $ (e.g. ^\d+$) so they must match the entire input rather than any substring.
• Read engine error messages literally: Nothing to repeat points at a stray quantifier, and Invalid escape names the bad backslash sequence.
Frequently Asked Questions
Letters that change matching: i (case-insensitive), m (^ and $ match line boundaries), s (dot matches newlines), u (unicode) and y (sticky). Type the ones you need into the Flags box, but skip g, because this tool already applies global matching internally when counting Total Matches.
The tool appends g by itself to count every match, so typing g in the Flags box produces a duplicate gg flag set that the RegExp constructor rejects. Clear the Flags box or use only i, m, s, u or y, global counting still works.
Without anchors, a regex succeeds on any substring, \d+ matches the 123 inside abc123def. If you are validating a whole field (port, IP octet, hostname), wrap the pattern as ^...$ so Has Match means the entire test string conforms.
No. Matching runs on your browser's native RegExp engine, pattern, flags and test string never leave your device, and closing the tab clears them from memory.
Sized this for your site?
Free engineers turn these numbers into a working design, topology, hardware and quote included.