Skip to content

Instantly share code, notes, and snippets.

@Dynyx
Created June 4, 2012 13:36
Show Gist options
  • Save Dynyx/2868427 to your computer and use it in GitHub Desktop.
Save Dynyx/2868427 to your computer and use it in GitHub Desktop.
Extract URLs from string
public static List<string> ExtractUrls(string source)
{
// match.Groups["name"].Value - URL Name
// match.Groups["url"].Value - URI
const string regexPattern = @"<a.*?href=[""'](?<url>.*?)[""'].*?>(?<name>.*?)</a>";
var matches = Regex.Matches(source, regexPattern, RegexOptions.IgnoreCase);
return (from Match match in matches select match.Groups["url"].Value).ToList();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment