Unix File Path
beginnerMatches Unix/Linux/macOS file paths.
filepathunixlinux
Pattern
/(?:/[\w.-]+)+/?/gTry It
0 of 6 strings matched
Explanation
Matches forward-slash-separated path components. Each component is one or more word characters, dots, or hyphens. Optional trailing slash for directories.
Test Strings
Matching
- /home/user/file.txt
- /var/log/syslog
- /usr/local/bin/
Non-matching
- relative
- C:\Windows
- nopath
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /(?:\/[\w.-]+)+\/?/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);