C
CSharper
I have the following code and the first expression get replaced
properly but the second one does not replace at all. Only difference
in the two, the later one has escape sequences inside the string.
static void Main(string[] args)
{
string key = "Tables";
string original = "select lot of tables";
string val = "yalks";
Regex myRegEx = new Regex(key,
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
string sRetStr = myRegEx.Replace(original, val);
key = @"name\age\sex";
original = @"select lot of tables with name\age\sex";
val = "columns";
myRegEx = new Regex(key,
System.Text.RegularExpressions.RegexOptions.IgnoreCase |
RegexOptions.CultureInvariant| RegexOptions.IgnorePatternWhitespace);
sRetStr = myRegEx.Replace(original, val);
}
What could be the problem?
Thanks,
properly but the second one does not replace at all. Only difference
in the two, the later one has escape sequences inside the string.
static void Main(string[] args)
{
string key = "Tables";
string original = "select lot of tables";
string val = "yalks";
Regex myRegEx = new Regex(key,
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
string sRetStr = myRegEx.Replace(original, val);
key = @"name\age\sex";
original = @"select lot of tables with name\age\sex";
val = "columns";
myRegEx = new Regex(key,
System.Text.RegularExpressions.RegexOptions.IgnoreCase |
RegexOptions.CultureInvariant| RegexOptions.IgnorePatternWhitespace);
sRetStr = myRegEx.Replace(original, val);
}
What could be the problem?
Thanks,