🔮 Write readable regular expressions
The crate provides a clean and readable way of writing your regex in the Rust programming language:
Without pretty_regex
With pretty_regex
\d{5}(-\d{4})?
digit
.repeats
.then
^(?:\d){4}(?:(?:\-)(?:\d){2}){2}$
beginning
.then
.then
.then
rege(x(es)?|xps?)
just
.then
How to use the crate?
To convert a PrettyRegex
struct which is constructed using all these then
, one_of
, beginning
, digit
, etc. functions into
a real regex (from regex
crate), you can call to_regex
or to_regex_or_panic
:
use digit;
let regex = digit.to_regex_or_panic;
assert!;