I have strings of the form:
greengrocerabc
sandwichcba
oscardcba
I'd like to lazily match abc, abcd and abcde, so I can get the first component. So something like
sub("^(.+)(abc|cba|dcba)", "\\1", "oscardcba") => "oscar"
However, regexp OR greedy matches cba and I get oscard
How can I lazy match this OR? The language is R, but it can can act like grep or perl.