pub trait Condition: AsRegex + Sized {
    fn and(self, other: impl AsRegex) -> Regex { ... }
    fn or(self, other: impl AsRegex) -> Regex { ... }
    fn optionally(self) -> Regex { ... }
}
Expand description

A trait, which allows to chain regex statements with conditions. Import this, if you want to use the and, or and optionally methods and chain statements.

Provided Methods§

Returns the regex, which chains the two given statements with an and condition.

Returns the regex, which chains the two given statements with an or condition.

Returns the regex, which sets the given statement to optional.

Implementations on Foreign Types§

Implementors§

Returns a Regex, which chains the 2 given regexes with an and operator.

Example

use magic_regexp::{create_reg_exp, Condition, Exactly, Digit, LetterLowercase};

let regex = create_reg_exp(Exactly(Digit).or(Exactly(LetterLowercase))).unwrap();
assert!(regex.is_match("1"));
assert!(regex.is_match("a"));
assert!(!regex.is_match("A"));
assert!(!regex.is_match("12"));
assert!(!regex.is_match("1a"));
assert!(regex.is_match("1 a"));