
Check if a string is alphanumeric (letters, digits, or underscores)
Source:R/utils.R
is_word_num.Rd
This function tests whether the input string consists entirely of
letters (a–z
, A–Z
), digits (0–9
), or underscores (_
).
Value
A logical vector the same length as ch
, where each element is TRUE
if the corresponding string contains only alphanumeric characters and underscores,
FALSE
otherwise.
Examples
is_word_num("alpha123") # TRUE
#> [1] TRUE
is_word_num("var_1") # TRUE
#> [1] TRUE
is_word_num("a-b") # FALSE
#> [1] FALSE
is_word_num(c("abc", "123", "a_b", "x-y")) # TRUE, TRUE, TRUE, FALSE
#> [1] TRUE TRUE TRUE FALSE