A regex engine answers one question: does this string match? RegexSolver answers questions about the patterns themselves: whether two rules overlap, whether a validator accepts more than it should, what one pattern matches that another does not.
const a = Term.regex("/api/v[12]/.*");
const b = Term.regex(".*/users/[0-9]+");
await client.intersection(a, b);Results are terms. Pass them straight into the next call.
import { RegexSolverClient, Term } from 'regexsolver';
const client = new RegexSolverClient({ apiToken: process.env.REGEXSOLVER_API_TOKEN });
const a = Term.regex("/api/v[12]/.*");
const b = Term.regex(".*/users/[0-9]+");
// Strings both patterns match. The result is a term.
const both = await client.intersection(a, b);
// Read it back as a regex when you need one
await client.getPattern(both);
// "/api/v[12]/(.*/)?users/[0-9]+"
// Or pass it on: does A match anything B does not?
const onlyA = await client.difference(a, b);
await client.isEmpty(onlyA);
// falseAnalyze a regex without running it: count the strings it matches, check if two patterns are equivalent, bound lengths.
Combine or merge multiple regex patterns into one with set algebra: union, intersection, difference and complement.
Generate strings matching a regex: distinct, deterministic, paginated results, with length and character-set bounds.
A regex engine executes one pattern against one string at a time. RegexSolver treats patterns as mathematical sets and answers structural questions about them: "do these two rules overlap?", "is this validator too permissive?", or "what strings exist in A but not B?"
Think of it as static analysis for your patterns: it inspects what they can match without ever executing them on real data.
Call the union operation with any number of patterns and it returns one pattern that matches everything the inputs matched. Intersection gives you the pattern both inputs accept, and difference subtracts one pattern from another.
The result is a single clean pattern, ready to use in your own code. See the pattern manipulation page for worked examples.
Call the equivalence operation with the two patterns and it answers by comparing the full languages they match, so patterns written in completely different ways still compare as equal when they accept the same strings.
The subset operation answers the related question of containment: whether everything one pattern matches is also matched by the other. See the regex analysis page for worked examples.
The RegexSolver engine is the open-source Rust library that implements the core set-algebra algorithms over finite automata; you can use it directly in your own Rust code.
The RegexSolver API builds on top of that engine and is exposed as a language-agnostic REST API, callable with any HTTP client, your own wrapper, or our official SDKs (JavaScript/TypeScript, Python, Java).
It also adds its own closed-source engine that converts automata back into compact, readable regex patterns, a capability the open-source library does not include.
RegexSolver supports standard character classes, quantifiers, alternation, and groups: the core constructs of pure regular languages. Patterns are implicitly anchored and always match the full string: abc matches "abc" but not "xabc" or "abcx".
Lookaheads, lookbehinds, and backreferences are not supported because they introduce context-sensitivity that makes set operations (intersection, complement, cardinality) undecidable. Keeping to pure regular languages is what makes the mathematical guarantees possible.
Yes, and this is one of RegexSolver's key strengths. Every compute operation can return a FAIR term (Fast Automaton Internal Representation), a compact binary encoding of the resulting automaton.
You can pass FAIR terms directly into subsequent API calls, skipping regex re-parsing and preserving all intermediate state with no overhead.
The core engine is written in Rust and operates on deterministic finite automata, which are immune to catastrophic backtracking (ReDoS) by construction. Every operation runs in bounded time.
For high-throughput runtime matching, the recommended pattern is to compute and cache an optimized regex with /analyze/pattern, then match it locally using your language's native engine; the SDKs include a client-side matches() method that does exactly this.
RegexSolver exposes a language-agnostic REST API, so any HTTP client works.
Official idiomatic SDKs are available for JavaScript/TypeScript (npm), Python (pip), and Java (Maven). All three are open-source and generated from the same OpenAPI spec.
The free tier covers 10,000 monthly API requests, enough for development, prototyping, and small-scale projects. Signing up requires no payment details of any kind.
See the pricing page for the full breakdown of limits.