filesstrings (version 0.4.0)

StringsWithPatterns: 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

StringsWithPatterns(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
StringsWithPatterns(c("abc", "bcd", "cde"), c("b", "c"))
StringsWithPatterns(c("abc", "bcd", "cde"), c("b", "c"), any = TRUE)
StringsWithPatterns(toupper(c("abc", "bcd", "cde")), c("b", "c"), any = TRUE)
StringsWithPatterns(toupper(c("abc", "bcd", "cde")), c("b", "c"), any = TRUE,
ignore.case = TRUE)

Run the code above in your browser using DataCamp Workspace