I have a character vector in which each entry looks like this:
"ABC1:123_CDE/CDE"
I would like to write a regular expression that matches ALL and ONLY characters trailing "_" so that I would get:
ABC1:123
I tried "^_$|[CDE/]"
but that seems to select the initial C as well.
I read somewhere that lookbehind can be used in R if you set perl = TRUE
, but I'm not super familiar with Perl regular expression matching either.
Many thanks, and apologies if there is something obvious I'm missing