I am not good with Regular Expressions. I recently attempted the following:
static void Main(string args)
const string NEXT_PATTERN = "<a href=\\\"(?<NextLink>.+?)\\\">Next Page</a></span>";
const string content = "SomeText <a href=\"LinkToExtract\">Next Page</a></span> SomeText";
MatchCollection matches = Regex.Matches(content, NEXT_PATTERN);
Console.WriteLine("Match Count = " + matches.Count);
Match m = matches;
string nextLink = m.Groups["NextLink"].Value;
Console.WriteLine("Next Link = " + nextLink);
I think this should not match i.e.
NEXT_PATTERN seems to have a Back Slash \ after the
href and before the end – while the content does not. I am really curious why this matches – and how to exclude this case.
Thanks a lot,
View Complete Post