assert_all_are_matching_fixed {assertive.strings} | R Documentation |
Checks to see if in the input matches a regular expression or fixed character pattern.
assert_all_are_matching_fixed(x, pattern, opts_fixed = NULL, na_ignore = FALSE, severity = getOption("assertive.severity", "stop")) assert_any_are_matching_fixed(x, pattern, opts_fixed = NULL, na_ignore = FALSE, severity = getOption("assertive.severity", "stop")) assert_all_are_not_matching_fixed(x, pattern, opts_fixed = NULL, na_ignore = FALSE, severity = getOption("assertive.severity", "stop")) assert_any_are_not_matching_fixed(x, pattern, opts_fixed = NULL, na_ignore = FALSE, severity = getOption("assertive.severity", "stop")) assert_all_are_matching_regex(x, pattern, opts_regex = NULL, na_ignore = FALSE, severity = getOption("assertive.severity", "stop")) assert_any_are_matching_regex(x, pattern, opts_regex = NULL, na_ignore = FALSE, severity = getOption("assertive.severity", "stop")) assert_all_are_not_matching_regex(x, pattern, opts_regex = NULL, na_ignore = FALSE, severity = getOption("assertive.severity", "stop")) assert_any_are_not_matching_regex(x, pattern, opts_regex = NULL, na_ignore = FALSE, severity = getOption("assertive.severity", "stop")) is_matching_fixed(x, pattern, opts_fixed = NULL, .xname = get_name_in_parent(x)) is_not_matching_fixed(x, pattern, opts_fixed = NULL, .xname = get_name_in_parent(x)) is_matching_regex(x, pattern, opts_regex = NULL, .xname = get_name_in_parent(x)) is_not_matching_regex(x, pattern, opts_regex = NULL, .xname = get_name_in_parent(x))
x |
string |
pattern |
pattern |
opts_fixed |
Passed to |
na_ignore |
should NAs be ignored or not? |
severity |
How severe should the consequences of the assertion be?
Either |
opts_regex |
Passed to |
.xname |
Not intended to be used directly. |
Aditya Bhagwat
stri_detect
, on which these functions are
based.
# Is it safe to eat oysters? is_matching_fixed(month.name, "r") # Sometimes it is easier to specify the negative match. is_matching_regex(LETTERS, "[^AEIOU]") is_not_matching_regex(LETTERS, "[AEIOU]") # Matching is vectorized over both x and pattern (pi_digits <- strsplit(format(pi, digits = 17), "")[[1]]) is_matching_regex(pi_digits, c("[13]", "[59]")) assert_any_are_matching_regex(pi_digits, c("[13]", "[59]")) # These checks should fail assertive.base::dont_stop({ assert_all_are_matching_regex(pi_digits, c("[13]", "[59]")) })