re2r (version 0.2.0)

re2_detect: Test a pattern in strings, and return boolean.

Description

Test a pattern in strings, and return boolean. Vectorised over strings and patterns.

Usage

re2_detect(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

A logical vector.

Examples

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

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

# vectorize
(res = re2_detect("This", letters))
letters[res]

letters[re2_detect("This", letters, case_sensitive = FALSE)]

letters[re2_detect("This", re2(letters, case_sensitive = FALSE))]

# In stringi, "" empty search patterns return NA.
# In re2r, empty search patterns will match
# empty string.

re2_detect("abc", "")
stringi::stri_detect("abc", regex = "")

# }

Run the code above in your browser using DataLab