RegexSolverRegexSolver
  • Live Demo
  • Docs
  • Pricing
  • Open Source ↗
  • Console ↗
Console ↗
  • Docs
  • API Reference
HELP
  • Documentation
  • Report an issue ↗
RESOURCES
  • Developer console
  • GitHub ↗
LEGAL
  • Privacy policy
  • Terms & conditions
RegexSolverRegexSolver

© 2026 REGEXSOLVER · ALL RIGHTS RESERVED

QuickstartAll OperationsSync and Async ClientsPlans and Pricing
Core Concepts
    Term's FormatUnion, Intersection, Difference and ComplementConcatenation and RepetitionEquivalence and SubsetAnalyzing a TermGenerate Strings
Guides
Advanced Usage
API Reference
Core Concepts

Analyzing a Term

These operations query a single Term and return a boolean or a number rather than a new Term.

Every result on this page is cached on the Term you passed in, so asking the same question twice about the same instance costs a single request. See Best Practices.

Empty

Check if the Term matches no strings.

The empty check is how most comparisons are resolved. An empty intersection proves two Terms can never match the same string, and an empty difference proves the first Term accepts nothing the second one rejects.

Code
RegexSolverClient client = RegexSolverClient.builder() .apiToken(System.getenv("REGEXSOLVER_API_TOKEN")) .build(); client.isEmpty(Term.regex("[]")); // true, the empty character class matches nothing client.isEmpty(Term.regex("abc")); // false

Totality

Check if the Term matches all the possible strings.

Its most common use is the mirror of empty: if the complement of a Term is empty, the Term is total, and a validation rule that is total rejects nothing.

Code
client.isTotal(Term.regex(".*")); // true client.isTotal(Term.regex(".+")); // false, it does not match the empty string

Empty String Only

Check if the Term matches only the empty string. This separates a Term whose only match is the empty string from one that matches nothing at all, a distinction the empty check cannot make.

Code
client.isEmptyString(Term.regex("")); // true client.isEmptyString(Term.regex("[]")); // false, this one matches nothing at all client.isEmptyString(Term.regex("a*")); // false, it also matches "a", "aa", ...

Cardinality

Compute how many strings the Term matches. The result takes one of three forms:

  • Integer: the language is finite and the exact count fits, so you get the number
  • BigInteger: the language is finite but the count exceeds what the engine returns exactly
  • Infinite: the language is unbounded, as with .*, a+ or .{2,}

"BigInteger" means the count is too large to return exactly, and not that it is mathematically infinite. A finite language always reports a finite category.

Code
client.getCardinality(Term.regex("abcde")); // Integer=1 client.getCardinality(Term.regex("[a-z]")); // Integer=26 client.getCardinality(Term.regex(".{1,10}")); // BigInteger client.getCardinality(Term.regex(".*")); // Infinite

Length

Compute the minimum and maximum length of strings matched by the Term, returned as min and max.

Two special cases:

  • A Term that matches nothing reports null for both bounds
  • A Term that can produce infinitely long strings reports null for max
Code
client.getLength(Term.regex("(abc)?d")); // min=1, max=4 client.getLength(Term.regex(".*")); // min=0, max=null client.getLength(Term.regex("[]")); // min=null, max=null
Last modified on August 8, 2026
Equivalence and SubsetGenerate Strings
On this page
  • Empty
  • Totality
  • Empty String Only
  • Cardinality
  • Length
Java
Java
Java
Java
Java