Check whether x matches the regular expression pattern. This is intended
for use inside assert(): unlike grepl(), which only returns
TRUE/FALSE and hides the input on failure, a failing has_match() shows
the actual string so you can see what was produced.
Arguments
- x
A character vector. Multiple elements are collapsed into a single string (separated by newlines) before matching.
- pattern
A regular expression. By default, matching uses Perl mode with the "dotall" flag enabled, so
.also matches newlines, which is convenient for searching multi-line text such as rendered HTML.- negate
If
TRUE, test thatxdoes not matchpattern. Prefer this over negating with!(e.g.!has_match(x, p)), sincenegatealso makes the failure message showx.- perl
Whether to use Perl-compatible regular expressions (which also enables the dotall flag).
- ...
Additional arguments passed to
grepl()(e.g.,ignore.case = TRUE).