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
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
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
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
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
nullfor both bounds - A Term that can produce infinitely long strings reports
nullformax
Code