Regex Tester
Test a regular expression against sample text.
What does this tool do?
This tool tests a JavaScript-flavored regular expression against a block of sample text and lists
every match it finds, in order, useful for building or debugging a pattern before dropping it into
code, a form validator, or a log search. Standard flags are supported: g (global, find
all matches instead of just the first), i (case-insensitive), m
(multiline, so ^/$ match line boundaries), and s (dot matches
newlines too).
How to use this tool
Enter a pattern (without the surrounding slashes), set flags if needed (g is on by
default so every match is found, not just the first), paste your test text, and click
Test Regex. Each match is listed on its own line in the output box; if nothing
matches, or the pattern itself is invalid, you'll see a clear message instead. Everything runs
locally in your browser; nothing is uploaded anywhere.
Common use cases
- Testing a validation pattern (like an email or phone number format) against real sample data before shipping it.
- Extracting all matching substrings, like URLs or hashtags, from a block of text.
- Debugging why a regex isn't matching what you expect it to.
- Learning regex syntax by experimenting against your own test strings.
Frequently asked questions
What do the different flags mean?
g (global) finds every match instead of stopping at the first; i makes matching case-insensitive; m (multiline) makes ^ and $ match the start/end of each line rather than the whole string; s makes . match newline characters too.
Why does my pattern match less than I expect?
A common cause is a greedy quantifier like .* matching too much or too little depending on context, or forgetting the g flag, which limits results to just the first match. Try adjusting one part of the pattern at a time against your test text to isolate the issue.
Is this the same regex engine as PHP or Python?
This tool uses your browser's JavaScript regex engine. It's very similar to PCRE (used by PHP) and Python's re module for most common patterns, but there are edge-case differences in features like lookbehind support and named group syntax, so always double-check a pattern in its actual target language before relying on it in production.