Certain regexes that are used with Regex::new
or RegexBuilder::new
may be
replaced by common str
methods, such as str::starts_with
, str::ends_with
,
str::contains
and str::cmp
.
let s = "Mary had a little lambda";
let re = Regex::new("^Mary").unwrap();
re.is_match(s);
let re = Regex::new("little").unwrap();
re.is_match(s);
let s = "Mary had a little lambda";
s.starts_with("Mary");
s.contains("little");