powered by
Check if the path starts with the dir path.
is_sub_path(x, dir, n = nchar(dir))
A logical vector.
A vector of paths.
A vector of directory paths.
The length of dir paths.
dir
xfun::is_sub_path("a/b/c.txt", "a/b") # TRUE xfun::is_sub_path("a/b/c.txt", "d/b") # FALSE xfun::is_sub_path("a/b/c.txt", "a\\b") # FALSE (even on Windows)
Run the code above in your browser using DataLab