Ok I'm giving up and ask the question after I read through the help article of regex and still don't have a clue what I'm looking for:
I Have a list of files:
files <- c("files_combined.csv","file_1-10.csv","file_11-20.csv", "file_21-30.csv","file_2731-2740.csv","file_2731-2740.txt") I want only the csv files that start with "file_" and end with ".csv". I know the it looks something like this:
grep(pattern = "^file_???.csv$" ,files) But I need to find the correct regular expression that ignores the number of characters between the first and the second pattern ("file_" + ".csv"). I'd really appreciate if somebody knows a complete list with the regular expressions in R since it is tedious to read through the help every time and, as in my case not successful, sometimes...
"^file_.*\\.csv$"maybe?grep("^file_.+\\.csv$",files,value=T)do what you want?