有没有一种方法可以在不使用 C# 中的正则表达式的情况下对字符串进行不区分大小写的替换?
像这样的东西
string x = "Hello";
x = x.Replace("hello", "hello world");
你可以尝试类似的东西
string str = "Hello";
string replace = "hello";
string replaceWith = "hello world";
int i = str.IndexOf(replace, StringComparison.OrdinalIgnoreCase);
int len = replace.Length;
str = str.Replace(str.Substring(i, len), replaceWith);
看一下String.IndexOf 方法(字符串、字符串比较) http://msdn.microsoft.com/en-us/library/ms224425.aspx
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)