| has_match | R Documentation |
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.
has_match(x, pattern, negate = FALSE, perl = TRUE, ...)
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 |
negate |
If |
perl |
Whether to use Perl-compatible regular expressions (which also enables the dotall flag). |
... |
Additional arguments passed to |
TRUE if x matches pattern (or does not match it when
negate = TRUE), otherwise FALSE.
library(testit)
assert('the page has a script but no style', {
html = '<html>\n<script>x</script>\n</html>'
(has_match(html, '<script>.*</script>'))
(has_match(html, '<style>', negate = TRUE))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.