Open
Description
grepl("^", x)
doesn't have a strict startsWith()
equivalent, but it is quite poor usage -- !is.na(x)
is clearly far superior.
x = c(NA, "", "abc")
cbind(
grepl = grepl("^", x),
starts_with = startsWith(x, ""),
is_na = !is.na(x)
)
# grepl starts_with is_na
# [1,] FALSE NA FALSE
# [2,] TRUE TRUE TRUE
# [3,] TRUE TRUE TRUE
Same goes for grepl("$", x)
Originally posted by @AshesITR in #1311 (comment)