Hi peeps,
I wonder if any of you .NET guys could try and figure out why my regex works in several tools, but when put into C# it fails?
Using RegExBuddy, Rad software Regular Expression Designer, Sells Brothers RegExDesigner.NET I can match the "title" group, but my C# fails to (although it gets the "href".
Using 1.1 of the Framework.
If anyone can see what's going wrong I'd be really chuffed.
Cheers,
DP
I wonder if any of you .NET guys could try and figure out why my regex works in several tools, but when put into C# it fails?
PHP Code:
string input = @"<a href=""http://www.thisisthedomain.com/"" class='big one' title=""testing & fixing & failing"">text here - More Text - some more</a>";
// Parse HTML for other attributes
Regex regex = new Regex(@"(<a\s+)*title\s*=\s*(?:""|')(?<title>[^'""]*)(?:""|')|class\s*=\s*(?:""|')(?<class>[^'""]*)(?:""|')|href\s*=\s*(?:""|')(?<href>[^'""]*)(?:""|')|rel\s*=\s*(?:""|')(?<rel>[^'""]*)(?:""|')", RegexOptions.IgnoreCase);
Match match = _regex.Match(input);
// Fetch named groups
_rel = match.Groups["rel"].Value;
_href = match.Groups["href"].Value;
_title = match.Groups["title"].Value;
_class = match.Groups["class"].Value;
Using 1.1 of the Framework.
If anyone can see what's going wrong I'd be really chuffed.
Cheers,
DP
Comment