Given this string:
DNS000001320_309.0/121.0_t0
How would I return everything before the second occurrence of \"_\"?
DNS0000
I think this might do the task (regex to match everything befor the last occurence of _):
_
_([^_]*)$
E.g.:
> sub('_([^_]*)$', '', "DNS000001320_309.0/121.0_t0") [1] "DNS000001320_309.0/121.0"