You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Allow dir_ls glob/regex patterns to ignore the supplied path #512
dir_ls glob/regex patterns act on the whole path, including what was passed by path. Often this can be accidentally misleading since the folder path itself contains a pattern (maybe even accidentally) that breaks the intended logic.
Request: it would be great if there were an argument to dir_ls to ignore the part of the path that was already supplied in path (effectively filtering only on the relative path).
If approved, I'm happy to put in a PR with the implementation above (and associated testing), given an agreed name for the argument (perhaps just relative?)
I've the same request. dir_ls(regex =) seems to match against the full path as opposed to list.files(pattern =) that matches against the actual elements of a path. The latter is more convenient and less confusing because it makes it easy to avoid matching undesired files or directories using ^ (rather than /).
I'd prefer dir_list() to behave like list.files() here. Also, I find it confusing that dir_ls(regexp = "^foo$") returns character(0). It would be useful to have a hint explaining why there's no match because the regexp is valid and the file exists.
Activity
orgadish commentedon Apr 1, 2026
If approved, I'm happy to put in a PR with the implementation above (and associated testing), given an agreed name for the argument (perhaps just
relative?)arnaudgallou commentedon Jul 6, 2026
I've the same request.
dir_ls(regex =)seems to match against the full path as opposed tolist.files(pattern =)that matches against the actual elements of a path. The latter is more convenient and less confusing because it makes it easy to avoid matching undesired files or directories using^(rather than/).Created on 2026-07-06 with reprex v2.1.1
I'd prefer
dir_list()to behave likelist.files()here. Also, I find it confusing thatdir_ls(regexp = "^foo$")returnscharacter(0). It would be useful to have a hint explaining why there's no match because the regexp is valid and the file exists.