c# - Regex to parse a string and match a URL or folder path -


i'm trying change regex match url http://www.google.com, , allow match folder name such j:\folder\name\here

i'm parsing text of message links may present within, , creating process.start(string) call matched string.

the regex have looks 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 add /{1,3} part match \{1,1} , might work, doesn't seem case.

i'm not sure else regex doing because did not write myself.

does have working example of regex match urls file system folder paths? or there way change existing regex work purpose?

have tried :

[^ ]+?:(//[^ ]*|\\.+\\[^ ]*) 

it match :

http://www.google.com 

and

c:\windows\temp internetfiles\ 

in string where http://www.google.com way go if want save file c:\windows\temp internetfiles\ quick , easy


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -