is_matching_fixed: Does the string match a pattern?

Description Usage Arguments Author(s) See Also Examples

View source: R/is-matching-fixed.R

Description

Checks to see if in the input matches a regular expression or fixed character pattern.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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))

Arguments

x

string

pattern

pattern

opts_fixed

Passed to stri_detect_fixed.

na_ignore

should NAs be ignored or not?

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

opts_regex

Passed to stri_detect_regex.

.xname

Not intended to be used directly.

Author(s)

Aditya Bhagwat

See Also

stri_detect, on which these functions are based.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# 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]"))
})

assertive.strings documentation built on May 1, 2019, 8:45 p.m.