filesstrings (version 2.0.1)

str_with_patterns: Which strings match the patterns?

Description

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).

Value

A character vector of strings matching the patterns.

Examples

Run this code
# 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)
# }

Run the code above in your browser using DataLab