The regex crate tells you whether a string matches a pattern. RegexSolver treats patterns as the sets of strings they match, so you can intersect, subtract, compare, complement and enumerate them, and get the result back as a regex.
Try it
Example
Use cases
- Safe migrations:
old.subset(&new)?tells you whether a new validation pattern accepts everything the old one did. - Equivalence proofs:
a.equivalent(&b)?shows that two patterns match the same strings. - Rule analysis:
intersectionanddifferencefind shadowed or overlapping routes, firewall rules and validators. - Test data:
generate_stringsproduces strings that match a pattern, spread over the cases it allows, reproducible and pageable. - Input bounds:
length()gives the shortest and longest string a pattern matches, to size a database column. - Readable regexes:
to_patternconverts every result back to a pattern, and neural synthesis can make it simpler: try both in the demo.
Semantics
- Everything is anchored:
abcmatches the string “abc”, not “xabc” or “abcx”. A pattern describes whole strings. .matches any character, including line feed.- Constructs a regular language can’t express, such as backreferences, lookaround, inline flags and word boundaries, return an error instead of changing what the pattern means.
- Automaton operations can blow up on adversarial patterns. To run untrusted input, set limits on run time and number of states with an
ExecutionProfile.
The hosted REST API and its SDKs have been retired: the crate is the way to use RegexSolver.