How to filter string vector by matching with another sequence of strings? Notice I'm supposed to run this on a large vector so this is just a simple example and the the |
delimated string is obtained from paste(ids,collapse="|")
. Here's an example:
> lapply(c("6:26762428[b38]","1:10177[b38]","1:10235[b38]"), function(x) grepl(x, c("6:26762428[b38]|6:27333733[b38]|14:105766248[b38]")))
[[1]]
[1] FALSE
[[2]]
[1] FALSE
[[3]]
[1] FALSE
The above should return TRUE, FALSE, FALSE
. Also it's better to be optimized for speed.