str_contains("hello", "hel")
str_contains("hello", "hal")
str_contains("hello", "Hel")
str_contains("hello", "Hel", ignore.case = TRUE)
# which patterns are in "abc"?
str_contains("abc", c("a", "b", "e"))
# is pattern in any element of 'x'?
str_contains(c("def", "abc", "xyz"), "abc")
# is "abcde" in any element of 'x'?
str_contains(c("def", "abc", "xyz"), "abcde") # no...
# is "abc" in any of pattern?
str_contains("abc", c("defg", "abcde", "xyz12"), switch = TRUE)
str_contains(c("def", "abcde", "xyz"), c("abc", "123"))
# any pattern in "abc"?
str_contains("abc", c("a", "b", "e"), logic = "or")
# all patterns in "abc"?
str_contains("abc", c("a", "b", "e"), logic = "and")
str_contains("abc", c("a", "b"), logic = "and")
# no patterns in "abc"?
str_contains("abc", c("a", "b", "e"), logic = "not")
str_contains("abc", c("d", "e", "f"), logic = "not")
Run the code above in your browser using DataLab