Suppose I want to exclude values matching a series of regular expressions from a character vector, in the same way that I would use setdiff()
for fixed character strings, e.g.
value <- c("apple pie", "cat", "dog", "dogmatic", "no apples")re_setdiff(value, c("^apple", "^dog"))## desired results:value[c(2,5)][1] "cat" "no apples"
I know how I can code this by brute force (see my answer) but am wondering if there's a more efficient/more idiomatic way to do it (maybe something in stringi
/stringr
?), or something that's already in a (widely used) package?