Function predicates::prelude::predicate::str::is_match[][src]

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

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"));