Sin decir muchas tonterías, todo está en el código, solo suba
Código JS:
La copia del código es la siguiente:
<html>
<Evista>
<script language = "javaScript">
var a = '<p> <a href =/' ~ abc/ccg/ab.jpg/'> text </a> <a style = "color: #ddd; font-weight: bold;" mm_href = "http: www.baidu.com" href = "http://bbs.cn.yimg.com/user_img/200701/31/soso1.jpg" mce_href = "http://bbs.cn.yimg.com/user_img/200701/31/jisuanji986_117025184198149.jpg"> cc </a> href = "www.baidu.com" cebas <span> cchref </span> 1 <a dd href = "ccc" ccc " <A href = "http://bbs.cn.yimg.com/user_img/200701/31/soso2.jpg" mce_href = "http://bbs.cn.yimg.com/user_img/200701/31/cc.jpg"> </a/<p> ';
var b =/<a ([/s]+| [/s]+[^<>]+[/s]+) href = (/"([^<>"/']*)/"|/' ([^<>"/']*)/') [^<>]*>/gi;
var s = a.tolowercase (). Match (b);
alerta (s.length);
para (var i = 0; i <s.length; i ++)
{
var ss = s [i] .tolowercase (). Match (b);
alerta (regexp. $ 3+regexp. $ 4);
}
</script>
</ablo>
<Body>
</body>
</html>
Código C#:
La copia del código es la siguiente:
cadena html = "<p> <a href = '~ abc/ccg/ab.jpg' height =/" 4/"width = '3'> text </a> <a width =/" 4/"style =/" color: #ddd; Font-Weight: Bold;/"mm_href =/" http: www.baidu.com/ "href =/" http://bbs.cn.yimg.com/user_img/200701/31/soso1.jpg/ "" mCE_HREF =/"http://bbs.cn.yimg.com/user_img/200701/31/jisuanji986_117025184198149.jpg/"> cc </a> href =/"www.baidu.com/" href =/"cc/" <a width =/"5/" href =/"http://bbs.cn.yimg.com/user_img/200701/31/soso2.jpg/" mce_href =/"http://bbs.cn.yimg.com/user_img/200701/31/cc.jpg/"> </a> </p> ";
Regex reg = new Regex ("<a ([// s]+| [// s]+[^<>]+[// s]+) href = (/" (? <href> [^<>/"']*)/" |' (? <href> [^<>/"']*)')^<>]*>", REGEXOPTIONS.IGNECASE);
MatchCollection MatchCollection = Reg.Matches (html);
MessageBox.Show (MatchCollection.count.ToString ());
foreach (coincidencia de coincidencia en coincidencia)
{
MessageBox.Show (Match.groups ["href"]. ToString ());
}
¿Has entendido las similitudes y diferencias de usar expresiones regulares en JS y C#? Si tiene alguna pregunta, deje un mensaje y discuta juntos.