File & Path
Unix File Path
Matches absolute Unix/Linux file paths.
Try it in RegexProPattern
regexJavaScript
/^(/[^/\0]+)+/?$/Raw source: ^(/[^/\0]+)+/?$
How it works
`^(/[^/\0]+)+` matches one or more path segments beginning with `/`, excluding null and additional slashes within segments. `/?$` allows optional trailing slash.
Examples
Input
/home/user/documentsMatches
/home/user/documents
Input
/var/log/Matches
/var/log/
Input
relative/pathNo match
—Common use cases
- Path validation
- File system tools
- Shell scripting