0

I have a dataframe with 1 column called filepath which contains file path:

filepath
C:\Windows\App\app1.exe
C:\Windows\App\folder1\app1.exe

I need to split up to the last backslash, and the exe file will be in another column. How should I split the directory path?

Below is the snapshot of the result I need to obtain.
newdata

I have tried regex expressions to obtain filepath1, eg:

df$filepath1 <- gsub("\\\\.*","",df$filepath)

but it doesnt work, because it will remove everything after the first match, and returning C: .

R_abcdefg
  • 145
  • 1
  • 11

0 Answers0