[Solved] Find hrefs value in string


Extend the capturing group around the “one or more not white space”

LinkParser = new Regex(@"\b(?<url>https?://\S+)['""]", RegexOptions.Compiled | RegexOptions.IgnoreCase);

Then access the match collection with

m.Groups["url"].Value

A simpler pattern might also work well: \b(?<url>http.*?)['"]

These are very primitive and I wouldn’t guarantee it works in all cases. If you have urls that aren’t quoted at all, consider adding Whitespace and close angle brackets to the end class. You’d be better off using a reliable library for this because …

1

solved Find hrefs value in string