Hi everyone I'm quite new to regular expressions and I'm trying to get srcs values out of img tags in html webpages, so I've made this regular expression: @"<img.*src *=*([\x22\x27])(?<path>.+)(\1).*/>"
But when I try to get the value frome the group "path" with this sample tag:
<img src='kkkkkk' class='icon' alt='' />
I get kkkkkk' class='icon' alt='
instead of just kkkkkk
. I just can't figure it out.
Here is the code I'm using to exctract and print the data:
Regex SrcRegex = new Regex(@"<img.*src *=*([\x22\x27])(?<path>.+)(\1).*/>", RegexOptions.IgnoreCase);
string TestTag = "<img src='kkkkkk' class='icon' alt='' />";
MatchCollection MatchedString = SrcRegex.Matches(ReadIn);
foreach (Match M in MatchedString)
Console.WriteLine(M.Groups["path"].Value);
Thanks guys for the attention and excuse me for my English.