I'm using mutate()
with str_extract()
to condense a string column in a dataframe to just a single key word column. My problem is that one of the strings contains two keywords, and it's the second one that's more important to me. The regex, though, always takes the first hit it finds to the alternatives I tell it to look for. Is there a way to change this?
MWE (without mutate()
):
teststring <- "abcdef"
str_extract(teststring, "b|c|a")
I'd like to be able to find patterns in the order I choose, not what's first in the test string.