Compare two patterns, check containment, count the strings a pattern matches and get its shortest and longest match length. Each answer is computed on the automaton and covers every string the pattern can match.
Each card calls the real API. Edit the patterns and compute. No signup.
| Operation | Notation | Answers | Returns |
|---|---|---|---|
| cardinality | |A| | How many distinct strings does the pattern match? | count | ∞ |
| length | len(A) | Shortest and longest possible match. | [min, max] |
| empty / total | A = ∅ · A = Σ* | Matches nothing at all? Matches everything? | boolean |
| equivalent | A ≡ B | Same language, regardless of syntax? | boolean |
| subset | A ⊆ B | Is every match of A also a match of B? | boolean |
| pattern | re(A) | A compact, human-readable regex for any term. | regex |
| empty_string | A = {ε} | Matches only the empty string? | boolean |
| deterministic | det(A) | Is the automaton deterministic? A stable string order requires it. | boolean |
| dot | dot(A) | The automaton as a Graphviz DOT graph, ready to render. | dot |
The main operations on this page, called through the official SDK.
import { RegexSolverClient, Term } from 'regexsolver';
const client = new RegexSolverClient({ apiToken: process.env.REGEXSOLVER_API_TOKEN });
// Same language, different syntax?
await client.equivalent(Term.regex("(abcd|abef)"), Term.regex("ab(cd|ef)"));
// true
// Is every match of A also a match of B?
await client.subset(Term.regex("beta-[0-9]{4}"), Term.regex("(alpha|beta)-[0-9]{4}"));
// true
// Number of strings the pattern matches
await client.getCardinality(Term.regex("[a-f0-9]{5}"));
// 1048576
// Shortest and longest possible match
await client.getLength(Term.regex("(alpha|beta|prod)-[a-z0-9]{4}"));
// [9, 10]
// Every match of A is a match of B when A minus B is empty
const gap = await client.difference(Term.regex("(abcd|abef)"), Term.regex("ab(cd|ef)"));
await client.isEmpty(gap);
// true