File & Path

Unix File Path

Matches absolute Unix/Linux file paths.

Try it in RegexPro

Pattern

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/documents

Matches

  • /home/user/documents

Input

/var/log/

Matches

  • /var/log/

Input

relative/path

No match

Common use cases

  • Path validation
  • File system tools
  • Shell scripting