Title |
Test
Find
Pattern Title
|
Expression |
^((([a-zA-Z]:)|(\\{2}\w+)|(\\{2}(?:(?:25[0-5]|2[0-4]\d|[01]\d\d|\d?\d)(?(?=\.?\d)\.)){4}))(\\(\w[\w ]*))) |
Description |
Regex to match valid folder paths. can be local, UNC with server name, or UNC with IP address |
Matches |
c:\ds\dsfsdf | \\192.168.14.118\23423 | \\fsdf\23423 |
Non-Matches |
c:\ | \\192.168.12.114 | \\fff |
Author |
Rating:
John Conwell
|
Source |
Put together from several patterns in regexlib |
Your Rating |
|
Title: Here's the better version
Name: swingnchad
Date: 6/23/2011 2:41:41 PM
Comment:
^((([a-zA-Z]:)|(\\{2}\w+[-\w+]*)|(\\{2}(?:(?:25[0-5]|2[0-4]\d|[01]\d\d|\d?\d)(?(?=\.?\d)\.)){4}))(\\(\w[\s*\w]*)))
Title: This version works with spaces and dashes
Name: swingnchad
Date: 6/23/2011 2:39:40 PM
Comment:
I modified it to accept folder names with spaces, and dashes in the computer/server name.
Title: Doesn't work with spaces
Name: swingnchad
Date: 6/23/2011 12:05:54 PM
Comment:
Doesn't match this valid path:
\\somepc\c\Documents and Settings\someuser
The spaces in the folder name mess it up