0

I found this

^\/(\/[^\s\/]+)+(\/)?$

But it matches right after the double forward slashes and any character

I need it to match to at least //servernameoripaddress/shareddir and it can go on from there ie. //Server Name or IP Address/Sharedfolder/Path/to/Saved/Files

Thank you all, I would appreciate any help for this.

Jenz
  • 8,280
  • 7
  • 44
  • 77
  • http://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address – Serjik Oct 08 '14 at 04:58

1 Answers1

2

Based on Regular expression to match DNS hostname or IP Address?:

^//(?:(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]))(?:/[^/]+)+$

Demo.

Explanation:

^// # make sure the string starts with two slashes
(?: # match an IP address...
    (([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])
| #... or a host name
    (([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])
)
(?:
    /[^/]+ # match a slash, followed by at least one character...
)+ #... at least once
$ # and make sure the string ends here
Community
  • 1
  • 1
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149