I have this mystring with the delimiter _. The condition here is if there are two or more delimiters, I want to split at the second delimiter and if th
mystring
_
With the stringr package:
stringr
str_extract(mystring, '.*?_.*?(?=_)|^.*?_.*(?=\\.ReCal)') [1] "MODY_60.2" "MODY_116.21" "MODY_116.3" "MODY_116.4"
It also works with more than two delimiters.