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)

Description

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

Usage

re2_detect(string, pattern)

Arguments

string

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

pattern

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.

Value

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.

Examples

## 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 May 29, 2024, 6:40 a.m.