您现在的位置是:首页 > 电脑技术查询 > web开发

请教用正则表达式怎么过虑[font *] *]*[ [/font]中的[font]标签

编辑:chaxungu时间:2022-10-02 23:16:58分类:web开发

请问用正则表达式如何过虑[font *****] ****]*[ [/font]中的[font]标签
我想要[font *****] ****]*[ [/font]中的 ****]*[ 内容就是把[font]标签过虑掉 中间的内容按原来显示(包括[]标签)

------解决方案--------------------
JScript code var str = '[font *****] ****]*[ [/font]'; var re = /\[[^\[]+?\]/gi; str = str.replace(re,''); alert(str)
------解决方案--------------------
\[[^\]]*?\].*?\[[^\]]*?\]
------解决方案--------------------
C# codestring str = @"[font *****] ****]*[ [/font]"; Regex re = new Regex(@"(?is)\[font\s+[^]]+\](.*?)[[^[]/font]"); foreach (Match ma in re.Matches(str)) { Response.Write(ma.Groups[1].Value); } /* 输出 ****]*[ */