re2_count(string, pattern, anchor = UNANCHORED, parallel = FALSE, grain_size = 1e+05, ...)
UNANCHORED
re2
Count the number of matches in a string. Vectorised over strings and patterns.
re2_count("one", "(o.e)")[1] 1re2_count("123-234-2222", "\\d\\d\\d-\\d\\d\\d-\\d\\d\\d\\d")[1] 1words = c("sunny","beach","happy","really") re2_count(words, "y")[1] 1 0 1 1re2_count(words, "^b")[1] 0 1 0 0re2_count(words, "[abc]")[1] 0 3 1 1# vectorize re2_count("This", letters)[1] 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0