Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Extracting string after second underscore and before dot R

I’m trying to keep strings after the second underscore and before dot. Thanks!

x <- "Exche_log_group_2.csv", "Exche_log_group_3.csv"

Desired output:

group_2  group_3

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

use gsub

gsub("[^_]+_[^_]+_|\\..*", "", x)
[1] "group_2" "group_3"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading