RegexOptions.IgnoreCase正则表达式替换,忽略大小写
程序员文章站
2023-12-15 11:12:58
//////////////////////////// &nbs...
////////////////////////////
string inputstr = "@{abcd},@{bbbb},@{abcd}";
string pmtype = "@";
string regtxt = (pmtype + "\\s*\\{\\s*" + "abcd" + "\\s*\\}").replace("(", "\\(").replace(")", "\\)");
//string regtxt = (pmtype + "\\s*\\{\\s*" + "aaaa" + "\\s*\\}").replace("(", "\\(").replace(")", "\\)");
// string regtxt = @"@\s*\{\s*aaaa\s*\}";
// string regtxt = @"@\s*\{\s*aaaa\s*\}/gi";
inputstr = regex.replace(inputstr, regtxt, "ccc", regexoptions.ignorecase | regexoptions.compiled);
///////////////
对于小文本不使用 regexoptions.compiled;