dir_ls - 如何使 "glob" 不区分大小写
dir_ls - how to make "glob" case insensitive
图书馆(fs)
dir_ls(glob = "*.R)
列出目录
中的所有 .R
文件
但是,dir_ls(glob = "*.r")
没有 return 任何东西
如何让 glob
不区分大小写?
使用 glob2rx
将 glob 转换为正则表达式,然后使用 list.files
和 ignore.case=TRUE
参数:
list.files(pattern = glob2rx("*.R"), ignore.case = TRUE)
您可以使用 fs::dir_ls()
中的 ...
参数将 ignore.case
传递给 grep()
:
dir_ls(glob = "*.r", ignore.case = TRUE)
图书馆(fs)
dir_ls(glob = "*.R)
列出目录
.R
文件
但是,dir_ls(glob = "*.r")
没有 return 任何东西
如何让 glob
不区分大小写?
使用 glob2rx
将 glob 转换为正则表达式,然后使用 list.files
和 ignore.case=TRUE
参数:
list.files(pattern = glob2rx("*.R"), ignore.case = TRUE)
您可以使用 fs::dir_ls()
中的 ...
参数将 ignore.case
传递给 grep()
:
dir_ls(glob = "*.r", ignore.case = TRUE)