首页 新闻 会员 周边

请问用正则表达式怎么去掉尖括号里面的内容,其他的方法也可以!

1
悬赏园豆:10 [待解决问题]

我的后台编译后的代码:<P style="TEXT-INDENT: 21pt; MARGIN: 0cm 0cm 0pt; mso-char-indent-count: 2.0"><FONT size=3><SPAN lang=EN-US><FONT face="Times New Roman">Visual C++ 6</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">有许多</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">Microsoft</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对</SPAN><SPAN lang=EN-US><FONT face="Times New Roman">Windows</FONT></SPAN><SPAN style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的特定扩展

我的C#代码:

 if (content.ContentDetail.Length > Length)
                    {
                        Regex pattern = new Regex("[\u4e00-\u9fa5]|[\uFE30-\uFFA0]|[_\a-zA-Z0-9]");
                        StringBuilder builer = new StringBuilder();
                        MatchCollection collection = pattern.Matches(content.ContentDetail);
                        foreach (Match m in collection)
                        {
                            builer.Append(m.ToString());
                        }

但是不行

我只想把尖括号和尖括号里面的内容去掉

请高手指点下,谢谢!

龙翔~的主页 龙翔~ | 初学一级 | 园豆:190
提问于:2010-12-22 20:41
< >
分享
所有回答(2)
0

using System.Text.RegularExpressions;
    public static string striphtml(string strhtml)
    {
        string stroutput = strhtml;
        Regex regex = new Regex(@"<[^>]+>|</[^>]+>");
copyright lyttzx.com

        stroutput = regex.Replace(stroutput, "");
        return stroutput;
lyttzx.com

    }

网上搜到的。

地址:http://www.lyttzx.com/plus/view.php?aid=4127

顾晓北 | 园豆:10844 (专家六级) | 2010-12-23 09:18
谢谢我尝试一下
支持(0) 反对(0) 龙翔~ | 园豆:190 (初学一级) | 2010-12-23 10:59
0

Regex.Replace(content, @"<[^>]*>", string.Empty, RegexOptions.Compiled);

dudu | 园豆:30943 (高人七级) | 2010-12-23 12:04
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册