What is the simplest way of removing text on both left and right side of a given character/text in r?
I have an example of the following dataset:
a = c("C:\\final docs with data/Gakenke_New_Sanitation.xlsx", "C:\\final docs with data/Gatsibo_New_Sanitation.xlsx", "C:\\final docs with data/Rutsiro_New_Sanitation.xlsx")
My expected output is to remain with: Gakenke, Gatsibo and Rutsiro.
I know, I can breakdown this task and handle it using mutate() as the following:
a %>% mutate(a = str_remove(a, "C.+/"), a = str_remove(a,"_.+")).
My question now is which simple pattern can I pass to that mutate function to remain with my intended results: Gakenke, Gatsibo and Rutsiro.
Any help is much appreciated. thank you!