您当前的位置: 首页 > 

Jave.Lin

暂无认证

  • 5浏览

    0关注

    704博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

以前几乎不怎么用正则,现在发现正则挺方便的

Jave.Lin 发布时间:2012-11-13 13:14:50 ,浏览量:5

测试DEMO:

            //测试正则

            Regex fontTagReg = new Regex("(?[^\\s\t\r\n\"\"']*)", RegexOptions.IgnoreCase);
            Regex aTagReg = new Regex(@".*", RegexOptions.IgnoreCase);

            string htmlText = "这是一段AS3的htmlText的Font标签内容:这是font的内容\n这是链接内容";

            MatchCollection mc = fontTagReg.Matches(htmlText);

            string matchStr = mc[0].Value;
            MessageBox.Show(matchStr);
            MessageBox.Show("font内容:"+mc[0].Groups["content"].Value);
            MessageBox.Show("font-color内容:" + mc[0].Groups["colorValue"].Value);

            mc = aTagReg.Matches(htmlText);
            matchStr = mc[0].Value;
            MessageBox.Show(matchStr);

参考资料:

1、C#正则表达式快速入门:

http://www.wangqi.com/n9250c53.aspx

2、C#正则表达式匹配HTML中的图片路径,图片地址:

http://www.cnblogs.com/xiaoyao2011/archive/2011/09/25/2190013.html

关注
打赏
1664331872
查看更多评论
立即登录/注册

微信扫码登录

0.1402s