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
_
^([^_\\n]*_[^_\\n]*)(?:_.*|\\.ReCal[^_]*)$
You can simply do using gsub without using any complex regex.Just replace by \\1.See demo.
gsub
\\1
https://regex101.com/r/wL4aB6/1