I have 2 character vectors:
Long <- c("d4@NHL1", "d7@NHL2", "d4@NHL3", "d7@NHL4", "d7@NHL5", "d9@NHL6")
Short <- c("NHL1", "NHL3", "NHL6", "NHL5")
I need to check which strings from Long vector partly match strings from Short vector, starting from @
symbol. I need to get a logic vector as a result.
I think I need to use grepl()
function, something like this:
sapply(Long, function(x) grepl(x, paste(Short, collapse = "")))
I don't know what to use as a pattern in grepl()
function or if there is any argument to start matching after a symbol.