Regex return file name, remove path and file extension
问题 I have a data.frame that contains a text column of file names. I would like to return the file name without the path or the file extension. Typically, my file names have been numbered, but they don't have to be. For example: df<-data.frame(data=c("a","b"),fileNames=c("C:/a/bb/ccc/NAME1.ext","C:/a/bb/ccc/d D2/name2.ext")) I would like to return the equivalent of df<-data.frame(data=c("a","b"),fileNames=c("NAME","name")) but I cannot figure out the slick regular expression to do this with gsub.