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

Extract specific strings

I have already loaded the data in R from various sheets, below you can see the names of the sheets. Below you can see the data and code:

df<-data.frame(
                  Tables=c("Export_A1.xlsx","Export_A2.xlsx","Export_A10.xlsx"))

enter image description here

So now I want to extract specific names, or in other words, I want to remove the text "Export_" and ".xlsx". Below you can see an example

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

enter image description here

So can anybody help me how to solve this problem ?

>Solution :

You can use the following code:

df$Tables <- gsub(".*[_]([^.]+)[.].*", "\\1", df$Tables)

df

Output:

  Tables
1     A1
2     A2
3    A10
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