欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

RegexOptions.IgnoreCase正则表达式替换,忽略大小写

程序员文章站 2023-12-04 16:09:52
////////////////////////////         &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;