Set algebra for regex.

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.

FIG. 1
Intersection
LIVE DEMO →
Σ*AB
const a = Term.regex("/api/v[12]/.*");
const b = Term.regex(".*/users/[0-9]+");

await client.intersection(a, b);
PATTERN/api/v[12]/(.*/)?users/[0-9]+
Analyze
Compute
Generate

Install and call.

Quickstart →

Results are terms. Pass them straight into the next call.

npm
npm i regexsolver
pip
pip install regexsolver
Maven
com.regexsolver.api:RegexSolver
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);
// false
Finite automata
Patterns are compiled to finite automata and the operations run on those. Every answer covers the whole language of the pattern.
Bounded time
There is no backtracking. Every request runs under a server-side execution timeout and an automaton-size limit, whatever the input pattern.
Chaining
The result of one operation can be passed straight into the next one. When you need a regex, ask for the result as a pattern.
Supported syntax
Pure regular expressions: character classes, quantifiers, alternation and groups. Patterns match the full string. Lookarounds and backreferences are not supported.
Open source
The automata engine is open-source Rust. The API adds the conversion from an automaton back to a readable regex.
  • Regex analysis

    Analyze a regex without running it: count the strings it matches, check if two patterns are equivalent, bound lengths.

  • Pattern manipulation

    Combine or merge multiple regex patterns into one with set algebra: union, intersection, difference and complement.

  • String generation

    Generate strings matching a regex: distinct, deterministic, paginated results, with length and character-set bounds.

Questions.

How is RegexSolver different from a regex engine or validator?

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.

How do I combine multiple regex patterns into one?

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.

How do I check if two regex patterns are equivalent?

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.

What's the difference between the RegexSolver engine and the RegexSolver API?

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.

Which regex syntax is supported? Can I use lookaheads or backreferences?

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.

Can I chain the output of one operation into another?

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.

Is it fast enough for production? Is it vulnerable to ReDoS?

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.

Which languages and platforms are supported?

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.

What does the free tier include?

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.