有没有办法在不使用C#中的正则表达式的情况下对字符串进行不区分大小写的替换?
这样的事情
string x = "Hello";
x = x.Replace("hello", "hello world");
Run Code Online (Sandbox Code Playgroud)
你可以尝试类似的东西
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);
Run Code Online (Sandbox Code Playgroud)
看看String.IndexOf方法(String,StringComparison)