str_with_patterns

0th

Percentile

Which strings match the patterns?

Given a character vector of strings and one of patterns (in regular expression), which of the strings match all (or any) of the patterns.

Usage
str_with_patterns(strings, patterns, ignore_case = FALSE, any = FALSE)
Arguments
strings

A character vector.

patterns

Regular expressions.

ignore_case

Do we want to ignore case when matching patterns?

any

Set this to TRUE if you want to see which strings match any of the patterns and not all (all is the default).

Details

For huge character vectors, this can be quite slow and you're better off implementing your own solution with stringr::str_detect().

Value

A character vector of strings matching the patterns.

Aliases
  • str_with_patterns
Examples
# NOT RUN {
str_with_patterns(c("abc", "bcd", "cde"), c("b", "c"))
str_with_patterns(c("abc", "bcd", "cde"), c("b", "c"), any = TRUE)
str_with_patterns(toupper(c("abc", "bcd", "cde")), c("b", "c"), any = TRUE)
str_with_patterns(toupper(c("abc", "bcd", "cde")), c("b", "c"), any = TRUE,
                  ignore_case = TRUE)
# }
Documentation reproduced from package filesstrings, version 2.5.0, License: GPL-3

Community examples

Looks like there are no examples yet.