I am very new to r and I have no experience with regular expressions and any help would be really appreciated.
I am reading in a dir
and I am trying to find files with the number "22953" and then I want to read the newest file containing this. The date is also written in the files' name.
Files in the directory:
inv_22953_20190828023258_112140.csv
inv_22953_20190721171018_464152.csv
inv_8979_20190828024558_112140.csv
The problem that I have here is that I can't really depend on the place of the string to get the date because as you can see some files might have fewer characters that is why maybe a solution would be to locate the date between the 2nd and 3rd.
filepath <- "T:/Pricing/Workstreams/Business Management/EU/01_Operations/02_Carveouts/05_ImplementationTest/"
list.files(filepath)[which.max(suppressWarnings(ymd_hm(substr(list.files(filepath, pattern="_22953"),11,22))))]```