re2_detect(string, pattern, anchor = UNANCHORED, parallel = FALSE, grain_size = 1e+05, ...)
UNANCHORED
re2
Test a pattern in strings, and return boolean. Vectorised over strings and patterns.
re2_detect("one", "(o.e)")[1] TRUEre2_detect("123-234-2222", "\\d\\d\\d-\\d\\d\\d-\\d\\d\\d\\d")[1] TRUEwords = c("sunny","beach","happy","really") re2_detect(words, "y")[1] TRUE FALSE TRUE TRUEre2_detect(words, "^b")[1] FALSE TRUE FALSE FALSEre2_detect(words, "[abc]")[1] FALSE TRUE TRUE TRUE# vectorize (res = re2_detect("This", letters))[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE FALSE FALSE [13] FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE [25] FALSE FALSEletters[res][1] "h" "i" "s"letters[re2_detect("This", letters, case_sensitive = FALSE)][1] "h" "i" "s" "t"letters[re2_detect("This", re2(letters, case_sensitive = FALSE))][1] "h" "i" "s" "t"# In stringi, "" empty search patterns return NA. # In re2r, empty search patterns will match # empty string. re2_detect("abc", "")[1] TRUEstringi::stri_detect("abc", regex = "")Warning message: empty search patterns are not supported[1] NA