Function xpct::match_regex
source · pub fn match_regex<'a, Actual>(
regex: impl AsRef<str>
) -> Matcher<'a, Actual, Actual>where
Actual: Debug + AsRef<str> + 'a,
Available on crate feature
regex
only.Expand description
Succeeds when the actual value matches the given regular expression.
This succeeds if the actual string contains any match for the given regex. If you want to test
that the regex matches the entire string, you should use the ^
and $
anchors.
The regex engine does not support lookarounds or backreferences.
Examples
use xpct::{expect, match_regex};
expect!("foobar").to(match_regex(r"^foo\w*$"));