Regex Equivalence Lab
Two regexes can agree on a few examples yet differ elsewhere. This tool converts each supported pattern to an NFA and explores combined states to decide language equivalence and inclusion. When they differ, it shows a shortest string accepted by only one side. Matching always covers the whole string; the alphabet is the 95 printable ASCII characters.
Key features
- Language equivalence and inclusion in both directions
- Shortest counterexamples for each difference
- Literals, groups, alternation, repetition and character classes
- Product-state transition list and Graphviz DOT export
- Explicit unsupported-syntax and state-limit errors
How to use
- Enter two patterns in the supported grammar.
- Run the language comparison.
- Review inclusion in both directions and quoted witnesses.
- Inspect sample product states and transitions.
- Download the full JSON or Graphviz DOT graph if needed.
Use cases
- Check whether a simplified regex accepts exactly the same strings
- Verify that one allow-rule language is contained in another
- Find a short test case exposing two patterns' difference
Frequently asked questions
Does this support all JavaScript regex features?
No. It supports printable ASCII literals, groups, |, *, +, ?, dot, character classes and ranges, plus \d, \w and \s. Backreferences, lookarounds, brace quantifiers and anchors are rejected.
What alphabet do dot and negated classes use?
Only the 95 printable ASCII characters U+0020 through U+007E. Newlines and Unicode are outside this language. \s means a space within this alphabet.
How is the empty-string witness shown?
It appears as two quotes, "". No witness is shown with a separate None label.
Does a size limit mean the patterns are equivalent?
No. Hitting the pattern, automaton or product-state limit produces an error and no verdict.
How does this differ from the regex tester?
The tester runs JavaScript regexes against entered sample text. This lab decides a relationship over every string in its stated, limited regular language and finds counterexamples.
Privacy
Patterns are computed in browser memory and are not uploaded. JSON and DOT files download locally.
Comments & questions