I want to replace text with Regex, and to use RegexOptions.IgnoreCase, but it is not working, when I have "(" in my text.
The code is:
var textToReplace = @" = CreateObject""(ADODB.Recordset)"";";
var retval = @" RsBO = CreateObject""(adodb.recordset)"";";
var Newtext = " = new Recordset();";
Regex regexText = new Regex(textToReplace, RegexOptions.IgnoreCase);
retval = regexText.Replace(retval, Newtext);
The result is:
RsBO = CreateObject\"(adodb.recordset)\";
But I want to see:
RsBO = new Recordset();
If I remove the chars '(' and ')', it works.
There are a few special characters in your expression:
(
and)
delimits a capture group, while.
represents any character (except line terminators).Try escaping
)
,(
and.
: