Back to Tools

Regex Syntax Validator

Instantly verify the integrity and compatibility of your regular expression patterns

SYNTAX PRO
/ /

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

  1. Type or paste your expression into Regex Pattern. The slashes on both sides are only decoration, so leave them out.
  2. Check the Flags box, which starts with g. Add i, m, s, u or y if you use them, or clear it entirely.
  3. Click Validate Syntax Integrity.
  4. 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


Frequently Asked Questions

Does the validator test whether my regex matches anything?
No. It only checks that the pattern and flags compile into a valid regular expression. To see what the pattern matches against sample text, use the Regex Tester, which highlights matches and lists capture groups.
Which regex flavor does it follow?
It follows the JavaScript flavor used by your browser. Common syntax is shared with PCRE, Python and Java, but some features differ, so a pattern accepted here may still need tweaks for another language.
Why do I get an error when the pattern looks correct?
Check the Flags field. Invalid or repeated flag letters trigger an error even with a correct pattern. Also look for unescaped special characters such as brackets, parentheses or a quantifier that has nothing before it.
Should I type the surrounding slashes?
No. The slashes drawn around the input box are decoration only. Enter the raw expression by itself, and put modifiers such as i or m in the separate Flags box beside it, exactly as the engine will receive them.
What does the error message mean?
It is the text produced by the JavaScript engine, such as an unterminated group, nothing to repeat, or an invalid escape. It usually names the problem and often the pattern, which helps you find the exact spot to fix.
Support Chat
We typically reply within minutes

Hello! 👋 Before we start, please tell us your name.