Best Answer hanzibal, 12 February 2013 - 11:29 AM
The RegEx variant of Replace is quite different from the ordinary String.Replace method. Regular expression strings can contain certain letters and patterns (like for instance paranthesis) that have special meaning. These are reserved and so if the string you pass in contains any of these you would typically get unexpected results.
An example where s+ means one or more white space characters:
var rx = new RegEx("s+");Debug.Print(rx.Replace("sushi is good", "-"));
The above would give yield the following resulting string:
sushi-is-good
But if you specify a non reserved pattern, like a literal "s", the method should work the same way as the ordinary Replace method would:
var rx = new RegEx("s");Debug.Print(rx.Replace("sushi is good", "-"));
-u-hi i- good
Does this answer your question?
Go to the full post