The crate provides a clean and readable way of writing your regex in the Rust programming language:
Without |
With |
|
digit() * 5 + (just("-") + digit() * 4).optional() |
|
beginning() + digit() * 4
+ (just("-") + digit() * 2) * 2
+ ending() |
|
just("rege") + (just("x") + just("es").optional())
| (just("xp") + just("s").optional()) |
To convert a PrettyRegex
into a regex from regex
crate, you can call to_regex
or to_regex_or_panic
:
use pretty_regex::digit;
let regex = (digit() + ascii_alphabetic().optional()).to_regex_or_panic();
assert!(regex.is_match("3"));