Created
June 4, 2012 13:36
-
-
Save Dynyx/2868427 to your computer and use it in GitHub Desktop.
Extract URLs from string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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