Relative File Path
beginnerMatches relative file paths starting with ./ or ../.
filepathrelativeimport
Pattern
/(?:\.{1,2}/)+[\w./+-]+/gTry It
0 of 6 strings matched
Explanation
Matches paths starting with ./ (current directory) or ../ (parent directory), followed by path components separated by forward slashes.
Test Strings
Matching
- ./src/index.ts
- ../package.json
- ../../lib/utils.ts
Non-matching
- /absolute/path
- just-a-file
- C:\path
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /(?:\.{1,2}\/)+[\w.\/+-]+/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);