str detect r code example
Example 1: str_detect regex r
x <- c("a.b.c.d", "aeb")
starts_with <- "a.b"
str_detect(x, paste0("^", starts_with))
#> [1] TRUE TRUE
str_detect(x, paste0("^\\Q", starts_with, "\\E"))
#> [1] TRUE FALSE
Example 2: if string in r
grepl(value, chars, fixed = TRUE)
# TRUE