c# - Isolate https://*something*.com from a bunch of text -
this question has answer here:
i have :string bunchoftext
contains link starts https://
, ends .com
. need isolate link , put in string. suggestions how? edit : text looks this:
it popularised in 1960s release of letraset sheets containing lorem ipsum passages, , more desktop publishing software aldus pagemaker including versions of lorem ipsum. https://mydomain/randomgeneratedtext.com why use it?
i want have new string
string link ="https://mydomain/randomgeneratedtext.com"
by time of edit, user : serhiyb, gave me perfect answer!
regex linkparser = new regex(@"https:\/\/(www\.)?[-a-za-z0-9@:%._\+~#=]{2,256}\.com\b([-a-za-z0-9@:%_\+.~#?&//=]*)?", regexoptions.compiled | regexoptions.ignorecase); string rawstring = "some text https://go.com link in it"; foreach(match m in linkparser.matches(rawstring)) console.writeline(m.value);
live demo: https://dotnetfiddle.net/zg8udj
it find links start https
, subdomain of .com
zone.
Comments
Post a Comment