0

Possible Duplicate:
Is there an alternative to string.Replace that is case-insensitive?

I'm looking for alternative to:

string str = "data ... ";
string replace = "data";
str = str.Replace(replace, "new value");
str = str.Replace(replace.ToLower(),"new value");

if possible using no regex. Thanks in advance.

Community
  • 1
  • 1
The Mask
  • 17,007
  • 37
  • 111
  • 185

1 Answers1

1

Without Regex, I don't know.

With Regex, it would give you something like this :

var regex = new Regex( str, RegexOptions.IgnoreCase );
var newSentence = regex.Replace( sentence, "new value" );

I found an interesting article here, with a sample code that looks to work faster than Regex.Replace : http://www.codeproject.com/KB/string/fastestcscaseinsstringrep.aspx

LaGrandMere
  • 10,265
  • 1
  • 33
  • 41