I recently had to perform some string replacements in .net and found myself developing a regular expression replacement function for this purpose. After getting it to work I couldn’t help but think there must be a built in case insensitive replacement operation in .Net that I’m missing?
Surely when there are so many other string operations that support case insensitive comparission such as;
var compareStrings = String.Compare("a", "b", blIgnoreCase);
var equalStrings = String.Equals("a", "b", StringComparison.CurrentCultureIgnoreCase);
then there must be a built in equivalent for replace?
Found one in the comments here: http://www.codeproject.com/Messages/1835929/this-one-is-even-faster-and-more-flexible-modified.aspx
Should be the fastest, but i haven’t checked.
Otherwise you should do what Simon suggested and use the VisualBasic Replace function. This is what i often do because of its case-insensitive capabilities.
You have to add a reference to the Microsoft.VisualBasic dll.