Intersect, subtract, union or complement patterns as sets. The result is a term you can pass to the next call, or read back as one regex pattern.
Each card calls the real API. Edit the patterns and compute. No signup.
| Operation | Notation | Answers | Returns |
|---|---|---|---|
| intersection | A ∩ B | Strings matching all of the patterns. | term |
| union | A ∪ B | Strings matching any of the patterns. | term |
| difference | A ∖ B | Strings in A but not in B. | term |
| complement | A | Every string the pattern does not match. | term |
| concatenation | A · B | Patterns joined in sequence. | term |
| repeat | A{n,m} | The pattern repeated n to m times. | term |
| determinize | dfa(A) | The same language as a deterministic FAIR, for a stable string order. | term |
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 });
// Strings both patterns match, as one pattern
const both = await client.intersection(
Term.regex("/api/v[12]/.*"),
Term.regex(".*/users/[0-9]+"),
);
await client.getPattern(both);
// "/api/v[12]/(.*/)?users/[0-9]+"
// Strings A matches and B does not
const noGif = await client.difference(
Term.regex(".*\\.(jpe?g|png|gif)"),
Term.regex(".*\\.gif"),
);
await client.getPattern(noGif);
// ".*\\.(jpe?|pn)g"
// Strings the pattern does not match
const rejected = await client.complement(noGif);
// Results are terms and can be passed to the next call.
// A term and its complement have no string in common:
await client.isEmpty(await client.intersection(noGif, rejected));
// true