废话不多说,都在代码中,直接上
JS代码:
复制代码 代码如下:
C#代码:
复制代码 代码如下:
string html = "
文字http://bbs.cn.yimg.com/user_img/200701/31/soso1.jpg" mce_href="cchttp://bbs.cn.yimg.com/user_img/200701/31/jisuanji986_117025184198149.jpg">cc href="www.baidu.com" cbas cchref 1http://bbs.cn.yimg.com/user_img/200701/31/soso2.jpg" mce_href="
http://bbs.cn.yimg.com/user_img/200701/31/cc.jpg">";Regex reg = new Regex("]+[\s]+)href=("(?
MatchCollection matchCollection = reg.Matches(html);
MessageBox.Show(matchCollection.Count.ToString());
foreach (Match match in matchCollection)
{
MessageBox.Show(match.Groups["href"].ToString());
}
小伙伴们是否了解了js及C#中使用正则表达式的异同点呢?有疑问的请留言,大家共同讨论。



