1
我想使用R的list.files列出包含此模式「un [a digit]」的文件,例如filename_un1.txt,filename_un2.txt等等......這裏是一般代碼:在R函數的list.files中使用正則表達式
list_files <- list.files(path="my_file_path", recursive = TRUE, pattern = "here I need help", full.names = TRUE)
我試圖把un\d
模式輸入,但不起作用。
嘗試'pattern =「_un \\ d + \\。txt $」' –
詳細說明,您需要轉義反斜槓。 – Peyton
或根據http://regexone.com/,簡單地''un \\ d +' – Gopala