re2_count: Count the number of matches in a string.

Description Usage Arguments Value Examples

Description

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

Usage

1
2
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

see UNANCHORED

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)

Example output

[1] 1
[1] 1
[1] 1 0 1 1
[1] 0 1 0 0
[1] 0 3 1 1
 [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

re2r documentation built on May 2, 2019, 12:35 p.m.