Click here to Skip to main content
15,888,816 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
HI,
I need to validate a file path through regular expression. I am reading log file from remote server from particular folder. So i need to validate the log file path like
\\106.103.20.111\test\test.txt. Can any one please help me out how to make in regular expression.
Posted
Comments
CHill60 31-Mar-15 4:47am    
Why ask the question again when you accepted the solution on your earlier post How to make validation for file path in asp.net.[^]

1 solution

This is one regex that is limited to your provided exampel
\\\\\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\\\w+\\\w+\.\w+


And this is a slightly more generic one, if the server name can be other than an IP address.
\\\\[\w\d.]+\\\w+\\\w+\.\w+


I recommend to get a tool for testing regular expressions, such as
RegExTest[^]
or
Visual Regexp[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900