str_detect_multiple: Detect the presence or absence of a patterns in a string.

Description Usage Arguments Value Examples

View source: R/str_detect_multiple.R

Description

Vectorised over 'string' and 'pattern'. Equivalent to str_detect, but capable of multiple patterns.

Usage

1
2
3
4
5

Arguments

string

Input vector. Either a character vector, or something coercible to one.

patterns

Patterns to look for as a character vector (e.g. c("foo", "bar) )

The default interpretation of each pattern in the character vector is a regular expression, as described in stringi::stringi-search-regex. Control options with regex().

Match a fixed string (i.e. by comparing only bytes), using fixed(). This is fast, but approximate. Generally, for matching human text, you'll want coll() which respects character matching rules for the specified locale.

Match character, word, line and sentence boundaries with boundary(). An empty pattern, "", is equivalent to boundary("character").

method

Match method: "and" or "or". "and" will only match strings where all patterns in the character vector are found in the string. "or" will match strings where any of the patterns in the character vector are found in the string.

Value

The part of the string after the first pattern and before the second pattern.

Examples

1
2
3
4
5
6
7
test_string <- 'complicated_file_name-32.csv'
str_detect_multiple(test_string, c('hadley', 'csv'), method = "and")
str_detect_multiple(test_string, c('hadley', 'csv'), method = "or")


str_detect_multiple_and(test_string, c('hadley', 'csv'))
str_detect_multiple_or(test_string, c('hadley', 'csv'))

johncassil/stringr.plus documentation built on Oct. 9, 2021, 7:56 p.m.