Vectorized over string.

str_detect_all(string, pattern, negate = FALSE)

str_detect_any(string, pattern, negate = FALSE)

Arguments

string

A character vector.

pattern

A character vector. The patterns to look for. Default is stringi-style regular expression. stringr::coll() and stringr::fixed() are also permissible.

negate

A flag. If TRUE, inverts the result.

Value

A character vector.

Examples

str_detect_all("quick brown fox", c("x", "y", "z"))
#> [1] FALSE
str_detect_all(c(".", "-"), ".")
#> [1] TRUE TRUE
str_detect_all(c(".", "-"), coll("."))
#> [1]  TRUE FALSE
str_detect_all(c(".", "-"), coll("."), negate = TRUE)
#> [1] FALSE  TRUE
str_detect_all(c(".", "-"), c(".", ":"))
#> [1] FALSE FALSE
str_detect_all(c(".", "-"), coll(c(".", ":")))
#> [1] FALSE FALSE
str_detect_all("xyzabc", c("a", "c", "z"))
#> [1] TRUE
str_detect_all(c("xyzabc", "abcxyz"), c(".b", "^x"))
#> [1]  TRUE FALSE

str_detect_any("quick brown fox", c("x", "y", "z"))
#> [1] TRUE
str_detect_any(c(".", "-"), ".")
#> [1] TRUE TRUE
str_detect_any(c(".", "-"), coll("."))
#> [1]  TRUE FALSE
str_detect_any(c(".", "-"), coll("."), negate = TRUE)
#> [1] FALSE  TRUE
str_detect_any(c(".", "-"), c(".", ":"))
#> [1] TRUE TRUE
str_detect_any(c(".", "-"), coll(c(".", ":")))
#> [1]  TRUE FALSE
str_detect_any(c("xyzabc", "abcxyz"), c(".b", "^x"))
#> [1] TRUE TRUE