Windows File Path
beginnerMatches Windows file paths with drive letter.
filepathwindowsvalidation
Pattern
/[A-Za-z]:\\(?:[\w.-]+\\)*[\w.-]+/gTry It
0 of 5 strings matched
Explanation
Matches a drive letter (A-Z) followed by :\ and backslash-separated path components.
Test Strings
Matching
- C:\Users\John\file.txt
- D:\Projects\src\main.ts
Non-matching
- /home/user/file.txt
- C:/path/file
- \\server\share
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /[A-Za-z]:\\(?:[\w.-]+\\)*[\w.-]+/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);Common Variations
UNC path
\\\\[\w.-]+(?:\\[\w.-]+)+Matches UNC network paths like \\server\share\file