predicates::str

Function is_match

Source
pub fn is_match<S>(pattern: S) -> Result<RegexPredicate, RegexError>
where S: AsRef<str>,
Expand description

Creates a new Predicate that uses a regular expression to match the string.

ยงExamples

use predicates::prelude::*;

let predicate_fn = predicate::str::is_match("^Hel.o.*$").unwrap();
assert_eq!(true, predicate_fn.eval("Hello World"));
assert_eq!(false, predicate_fn.eval("Food World"));