Regex Syntax Validator
Instantly verify the integrity and compatibility of your regular expression patterns
Find out if your regular expression is even legal
Before worrying about whether a pattern matches the right strings, you need to know that it compiles at all. A stray parenthesis, an unescaped bracket or a quantifier with nothing to repeat will make a regex engine throw an error, and in production that can crash a form handler. The Regex Validator does one narrow job: it tries to build your pattern and reports either success or the engine's own error message.
How to validate a pattern
- Type or paste your expression into Regex Pattern. The slashes on both sides are only decoration, so leave them out.
- Check the Flags box, which starts with g. Add i, m, s, u or y if you use them, or clear it entirely.
- Click Validate Syntax Integrity.
- A green card headed Perfect Syntax means the pattern compiled. A red card headed Syntax Error Detected shows the message from the engine, for example that a group is unterminated or a quantifier is out of order.
If the pattern field is empty, nothing happens.
What the check does and does not prove
The tool constructs a JavaScript regular expression object with your pattern and flags, and nothing else. Compilation success tells you the syntax is acceptable to your browser's engine. It says nothing about what the pattern matches, whether it is efficient or whether it matches the strings you expect. For that, use the Regex Tester with sample text. The green message describes the pattern as compatible with modern engines, but that is a general reassurance: other languages have their own rules, so a pattern that passes here may still fail elsewhere.
Where it is handy
- Checking a pattern a user typed into a settings field before saving it to a config file.
- Debugging a regex copied from documentation, where one escape character got lost in formatting.
- Confirming that a set of flags such as the sticky or unicode flag is accepted.
- Learning what error messages look like for common mistakes like an empty group or a bad range.
Points to remember
Flags are validated too. An unknown or duplicated flag letter, such as gg or a letter that is not a regex flag, produces an error even if the pattern itself is fine. Constructs that differ between languages will be judged by JavaScript rules. Lookbehind is accepted by current browsers but may not work in older ones or in certain other languages, and features like possessive quantifiers or inline modifiers that exist elsewhere will be reported as errors here.
If you are building a pattern for a string literal in code, remember that backslashes typically need doubling there; the validator expects the raw pattern text, exactly as the regex engine will see it. The check runs entirely in your browser using JavaScript.
Related Tools
Related Tools