I am converting some code from Perl into .NET. I have this s/// pattern replacement:
$text =~ s/<A HREF="([^"]+)">\Q\1\E</A>"/$1/gi;
I use the Perl \Q and \E to escape the text I am matching in the first capture, the URL portion of an HREF attribute.
How do I do the same thing in .NET? I've read about using Regex.Escape() to escape text for a regular expression, but how can I use it WITHIN the regular expression that is performing the match? (Or do I even need to do that?)
So right now I'm not doing anything special, and wondering if this will continue to work as well as my Perl regex has been:
text = Regex.Replace(text, @"<A HREF=""([^""]+)"">\1</A>", "$1", RegexOptions.IgnoreCase);