About the Regex Tester
Regular expressions are powerful but notoriously easy to get subtly wrong — an extra character class, a missing anchor, or the wrong flag can make a pattern match too much, too little, or nothing at all.
This tool lets you write a regular expression, test it against sample text live, and see every match highlighted directly in context using standard JavaScript regex syntax.
How it works
- Type your regular expression pattern into the pattern field, without the surrounding slashes.
- Set flags (like `g` for global, `i` for case-insensitive) as needed.
- Type or paste your test text, and matches are highlighted automatically as you adjust the pattern.
Common use cases
- Validating an input format: Building and testing a pattern like an email or phone number validator against a range of valid and invalid example inputs before adding it to a form.
- Extracting data from log lines: Testing a capture-group pattern against sample log lines to confirm it correctly extracts the fields you need before using it in a parsing script.
- Debugging an existing regex: Pasting in a regex from your codebase along with real input that isn't matching as expected, to see exactly where the pattern breaks down.
Frequently asked questions
What does the 'g' flag do?
The global flag makes the regex find all matches in the text rather than stopping after the first one — without it, only the first match (if any) is reported, which is easy to forget when testing a pattern meant to match repeatedly.
Why does my pattern work here but not in my code?
Double-check that flags match (especially case-insensitivity with `i` and multiline with `m`), that special characters are escaped consistently with how your programming language handles regex string literals, and that you're not accidentally including the enclosing slashes or quotes as part of the pattern itself.
What's the difference between greedy and lazy quantifiers, like * and *??
A greedy quantifier (like `.*`) matches as much text as possible before backtracking if needed, while a lazy quantifier (`.*?`) matches as little as possible — this matters most with patterns spanning repeated delimiters, like extracting text between quotes when there are multiple quoted sections on one line.
Why did I get a 'regex is not valid' error?
The pattern has invalid regex syntax — common causes include an unclosed group `(`, an unescaped special character where a literal was intended, or an invalid combination of flags for the JavaScript regex engine.
This tool runs entirely in your browser — nothing you enter is sent to a server. Read more in the Privacy Policy, or browse the full list of tools.