This is a simple toy example. I would like to only keep the shortest sub-string. AB we keep and ABC can be excluded. BD and ADB we keep because there is no langer character that also has this pattern.
have <- c('AB', 'BD', 'ADB', 'ABC')
want <- c('AB', 'BD', 'ADB')
grepl is very useful here but I'm not sure how to make it computationally efficient.