首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

请问一正则表达式,请!

2012-06-19 
请教一正则表达式,请高手进!!!!diva href/common/pub.php?categoryhousing&type1a href/comm23

请教一正则表达式,请高手进!!!!

<div>
<a href="/common/pub.php?category=housing&type=1"
<a href="/comm234on/pu234b.php?category=housin13g&type=241"
</div>

这样一个字符串,要求找出""引号部分的字符串,得到结果:/common/pub.php?category=housing&type=1 /comm234on/pu234b.php?category=housin13g&type=241

请高手贴出代码,谢谢!!!

[解决办法]

C# code
            StreamReader reader = new StreamReader("e:\\1.txt");            string content = reader.ReadToEnd();            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"(?<=<a href=""[^""]*?)[^""]+(?="")");            System.Text.RegularExpressions.MatchCollection ms = reg.Matches(content);            foreach (System.Text.RegularExpressions.Match m in ms)            {                MessageBox.Show(m.Value);            }
[解决办法]
(?i)<a\b[^>]*href=(["'\s]?)(.*?)\1[^>]*>
取第二个分组,Groups[2].Value

热点排行