re2r (version 0.2.0)

re2_count: Count the number of matches in a string.

Description

Count the number of matches in a string. Vectorised over strings and patterns.

Usage

re2_count(string, pattern, anchor = UNANCHORED, parallel = FALSE,
  grain_size = 1e+05, ...)

Arguments

string

a character vector

pattern

a character vector or pre-compiled regular expressions

anchor
parallel

use multithread

grain_size

a minimum chunk size for tuning the behavior of parallel algorithms

...

further arguments passed to re2

Value

An integer vector.

Examples

Run this code
# NOT RUN {
re2_count("one", "(o.e)")
re2_count("123-234-2222", "\\d\\d\\d-\\d\\d\\d-\\d\\d\\d\\d")

words = c("sunny","beach","happy","really")
re2_count(words, "y")
re2_count(words, "^b")
re2_count(words, "[abc]")

# vectorize
re2_count("This", letters)
# }

Run the code above in your browser using DataLab