i am trying to fetch anything that looks like a URL from a string
how would i do this with c#?
most of the are going to look like this: http://www.something.com, but some may look like this: http://something.somethingelse.com
i am trying to fetch anything that looks like a URL from a string
how would i do this with c#?
most of the are going to look like this: http://www.something.com, but some may look like this: http://something.somethingelse.com
You'll want to use RegEx for that. Here's a handy article that will get you started. It's an ASP.NET article that wants to find URLs and turn them into hyperlinks but performs the activity you're interested in.
Assuming you're parsing some [X]HTML - Use the HTML Agility Pack.
Straight from the examples page:
foreach(HtmlNode link in doc.DocumentElement.SelectNodes("//a[@href"])
{
HtmlAttribute att = link["href"];
//Do stuff
}
This really depends on the context, but you will generally use regular expressions (System.Text.RegularExpressions.Regex class). To get more specific answers, like code, you will need to provide what the surrounding string might look like so that we know how to differentiate url from non-url.