I have a set of 'filename.extension's and I want to extract just the filename. I am having trouble extracting the full filename when the filename shares a character with the file extension. for example, the filename.extension "qrs.sas7bdat" has
filename="qrs"
extension="sas7bdat"
In this case one may observe that the filename shares in common with the extension the character "s".
Here's some R code to give more context:
files_sas <- c("abc.sas7bdat","qrs.sas7bdat")
stringr::str_extract(files_sas,"(?:.*|.*s)[^\\.sas7bdat]")
This set of code returns the following character vector:
"abc" "qr"
This is not what I want -- the desired result I want follows:
c("abc","qrs")
It looks like I'm close, and so I am hoping someone might be able to help me get my desired result.
Many thanks.