re2_detect: Find the presence of a pattern in string(s)

View source: R/RcppExports.R

re2_detectR Documentation

Find the presence of a pattern in string(s)


Equivalent to grepl(pattern, x). Vectorized over string and pattern. For the equivalent of grep(pattern, x) see re2_which.


re2_detect(string, pattern)



A character vector, or an object which can be coerced to one.


Character string containing a regular expression, or a pre-compiled regular expression (or a vector of character strings and pre-compiled regular expressions).
See re2_regexp for available options.
See re2_syntax for regular expression syntax.


A logical vector. TRUE if match is found, FALSE if not.

See Also

re2_regexp for options to regular expression, re2_syntax for regular expression syntax, and re2_match to extract matched groups.


## Character vector input
s <- c("barbazbla", "foobar", "not present here ")
pat <- "(foo)|(bar)baz"
re2_detect(s, pat)

## Use precompiled regexp
re <- re2_regexp("(foo)|(bAR)baz", case_sensitive = FALSE)
re2_detect(s, re)

re2 documentation built on March 29, 2022, 5:05 p.m.