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

Description Usage Arguments Value Examples

Description

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

Usage

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

see UNANCHORED

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 = "")

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