1
Vote

String Extension Replace method fails with value containing backslash

description

Hi.
 
String Extension Replace method fails with value containing backslash
 
string s = "Hello\New\World!";
string results = s.Replace("world", "Dude", false);
 
System.ArgumentException: parsing "Hello\New\World" - Unrecognized escape sequence \N.
at System.Text.RegularExpressions.RegexParser.ScanCharEscape()
at System.Text.RegularExpressions.RegexParser.ScanBasicBackslash()
at System.Text.RegularExpressions.RegexParser.ScanRegex()
at System.Text.RegularExpressions.RegexParser.Parse(String re, RegexOptions op)
at System.Text.RegularExpressions.Regex..ctor(String pattern, RegexOptions options, Boolean useCache)
at Edge.Extensions.StringExtensions.Replace(String s, String oldString, String newString, Boolean caseSensitive) in C:\Edge\edgeextensions\Edge.Extensions\StringExtensions.cs:line 1006
...

comments