I'm trying to change a regex that will match a url like http://www.google.com
, and also allow it to match a folder name such as j:\Folder\Name\Here
I'm parsing the text of a message for any links that may be present within, and creating a Process.Start(string) call with the matched string.
The regex I have now looks like this:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'"".,<>?«»“”‘’]))
I'm thought I could add to the /{1,3}
part to match \{1,1}
also and it might work, but that doesn't seem to be the case.
I'm not sure what else the regex is exactly doing because I did not write it myself.
Does anyone have a working example already of a regex that will match URLs as well as file system folder paths? Or is there some way to change this existing regex to work for that purpose?