Check that a vector conforms to a certain pattern.

chk_regex(x, pattern)

chk_max_length(x, len)

Arguments

x

A vector to check.

pattern

A str_detect() pattern to match.

len

Maximum string length.

Value

A logical vector flagging records that have passed or failed the check.

Examples


x <- c("a_1", "b_2", "c_2", NA, "NULL")
chk_regex(x, "[a-z]_[0-9]")
#> [1]  TRUE  TRUE  TRUE  TRUE FALSE
chk_max_length(x, 3)
#> [1]  TRUE  TRUE  TRUE  TRUE FALSE