I have a string that looks like this:
BA46_05-07-2019_rxn2_AAGAACATCCCTCTCC
I want to remove everything between rxn2 and BA46_
Desired end results:
BA46_rxn2_AAGAACATCCCTCTCC
How can I do this?
I have a string that looks like this:
BA46_05-07-2019_rxn2_AAGAACATCCCTCTCC
I want to remove everything between rxn2 and BA46_
Desired end results:
BA46_rxn2_AAGAACATCCCTCTCC
How can I do this?
Try this
x <- "BA46_05-07-2019_rxn2_AAGAACATCCCTCTCC"
sub("_[0-9\\-]*_" , "_" , x)
[1] "BA46_rxn2_AAGAACATCCCTCTCC"
library(stringr)
str_remove(string, '\\d{2}\\-\\d{2}\\-\\d{4}\\_')
[1] "BA46_rxn2_AAGAACATCCCTCTCC"
sub('(.*BA46_).*(rxn2.*)','\\1\\2', 'BA46_05-07-2019_rxn2_AAGAACATCCCTCTCC')
I would go with this because it
BA46_ and rxn2 once, thus reducing the room for error