一个可能得到任何格式的链接的正则,<html>
<head>
<title>无标题</title>
<head>
<body>
<textarea id=text></textarea> 
<textarea onclick='text.value=this.value.match(/< *a[^<>]*>[^<>]+< *\/a *>/)'>
hhh<a 
href=#
>ddd
d
</a>hhh
</textarea> 
</body>
</html>

解决方案 »

  1.   

    哦,上面的应该是行的,不过我A链接中间可以出现Font之类的标签啊,不能用[^<>]吧
      

  2.   

    qidizi(qidizi):看看这段,我怎么替都替不掉......用上面的依然.....<TABLE cellSpacing=0 cellPadding=0 width=320 border=0>
    <TBODY>
    <TR>
    <TD width=102><IMG class=img01 height=70 alt=视觉联盟 src="newimg0.gif" width=93 
    border=0> <!-- end Jin2 --></TD>
    <TD vAlign=top width=219><!-- Jin3 --><FONT color=#0031ff>点击今日</FONT></A><SPAN 
    class=blue3><FONT color=#0031ff>|</FONT></SPAN><A class=blue1 href="http://news.sohu.com/s2005/05xjbtk.shtml" target=_blank><FONT 
    color=#000099>新京报2005图鉴:目击盛世图景</FONT></A><BR><!-- end Jin3 --><!-- Jin4 --><A 
    class=blue3 
    href="http://index.news.sohu.com/zhuanti/zhuanti_last.php?psortname=新闻&amp;psortid=1&amp;sortid=155" 
    target=_blank><FONT color=#0031ff>新闻人物</FONT></A><SPAN class=blue3><FONT 
    color=#0031ff>|</FONT></SPAN><A class=blue1 
    href="http://news.sohu.com/s2005/05zhangziyi.shtml" target=_blank><FONT 
    color=#000099>演日艺伎被骂 章子怡冤不冤?</FONT></A><BR><!-- end Jin4 --><!-- Jin5 --><A 
    class=blue3 href="http://star.news.sohu.com/" target=_blank><FONT 
    color=#0031ff>日 月 谈</FONT></A><SPAN class=blue3><FONT 
    color=#0031ff>|</FONT></SPAN><A class=blue1 href="http://star.news.sohu.com/" 
    target=_blank><FONT color=#000099>谭咏麟也有二奶和私生子?/图</FONT><A><BR><!-- end Jin5 --><!-- Jin6 --><A 
    class=blue3 href="http://business.sohu.com/s2004/xingkong.shtml" 
    target=_blank><FONT color=#0031ff>财经评论</FONT></A><SPAN class=blue3><FONT 
    color=#0031ff>|</FONT></SPAN><A class=blue1 
    href="http://business.sohu.com/20051111/n240698085.shtml" target=_blank><FONT 
    color=#000099>房地产商为什么被千夫所指?</FONT><BR><!-- end Jin6 --></A></TD></TR></TBODY></TABLE>
    <TABLE cellSpacing=0 cellPadding=0 width=320 border=0>
    <TBODY>
    <TR>
    <TD colSpan=2><!-- Jin7 --><FONT color=#0031ff>企业调查</FONT></A><SPAN 
    class=blue3><FONT color=#0031ff>|</FONT></SPAN><A class=blue1 
    href="http://business.sohu.com/s2005/yuekai.shtml" target=_blank><FONT 
    color=#000099>乐凯的夕阳之歌</FONT></A> <A class=blue3 
    href="http://it.sohu.com/pinglun.shtml" target=_blank><FONT 
    color=#0031ff>左右间</FONT></A><SPAN class=blue3><FONT 
    color=#0031ff>|</FONT></SPAN><A class=blue1 
    href="http://it.sohu.com/pinglun.shtml" target=_blank><FONT 
    color=#000099>你怎么看待校园A片现象</FONT></A><BR><!-- end Jin7 --><!-- Jin7_1 --><A 
    class=blue3 href="http://auto.sohu.com/" target=_blank><FONT 
    color=#0031ff>酒后开车</FONT></A><SPAN class=blue3><FONT 
    color=#0031ff>|</FONT></SPAN><A class=blue1 
    href="http://auto.sohu.com/s2005/jiuhoukaiche.shtml" target=_blank><FONT 
    color=#000099>买车 为啥总是我受伤?</FONT></A> <A class=blue3 
    href="http://house.sohu.com/housenewscenter/houseonline/" target=_blank><FONT 
    color=#0031ff>房产</FONT></A><SPAN class=blue3><FONT 
    color=#0031ff>|</FONT></SPAN><A class=blue1 
    href="http://house.focus.cn/jiaodianpk/pointkill5.php" target=_blank><FONT 
    color=#000099>期房与现房间的PK</FONT></A><!-- end Jin7_1 --> <!-- Jin8 --><A 
    class=blue3 href="http://yule.sohu.com/vipchat.shtml" target=_blank><FONT 
    color=#0031ff>明星在线</FONT></A><SPAN class=blue3><FONT 
    color=#0031ff>|</FONT></SPAN><A class=blue1 
    href="http://yule.sohu.com/s2005/gjjzk.shtml" target=_blank><FONT 
    color=#000099>古巨基"受刺激"</FONT></A> <A class=blue1 
    href="http://yule.sohu.com/s2005/zjzk.shtml" target=_blank><FONT 
    color=#000099>郑钧看超女:是世界还是我疯了?</FONT><BR><!-- end Jin8 --></A></TD></TR></TBODY></TABLE><!-- 精品3[游戏] -->
    <TABLE cellSpacing=0 cellPadding=0 width=333 border=0>
    <TBODY>
    <TR>
    <TD align=middle bgColor=#f5fad0 height=22><!-------游戏 1条 开始------>
    <TABLE cellSpacing=0 cellPadding=0 width=320 border=0>
    <TBODY>
    <TR>
    <TD><FONT color=#0031ff>游戏</FONT></A><SPAN class=blue3><FONT 
    color=#0031ff>|</FONT></SPAN><A class=blue1 
    href="http://ko.sohu.com/index.shtml" target=_blank><FONT 
    color=#000099>网游任你玩玩玩</FONT></A> <A class=blue1 
    href="http://adnet.sohu.com/goto.php3?code=xinq01-1031sh" target=_blank><FONT 
    color=#000099>享乐人群活跃专区</FONT></A> <A class=blue1 
    href="http://bo.sohu.com/events/051031/index.html" target=_blank><FONT 
    color=#000099>全国掀起斗神狂潮 
    </FONT></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
      

  3.   

    求个可以匹配任何字符的正则!!!
    比如[^<]除了<以外,我要包括<怎么办?
      

  4.   

    var regex = /<a\s+[^>]+>[^.](.*)<\/a>/ig;
      

  5.   

    我用了个有点垃圾的办法,不过是行得通的
    var RegEx = /< *a *[^<>]*>([^\f]+?)< *\/a *>/ig;
    这种可以取任意一段源码内的所有链接(用了楼上qidizi(qidizi)老兄的),然后
    sContent = sContent.replace(RegEx,"$1");
    就可以去掉sContent源码中所有的链接了.因为我不知道怎么搞个匹配任何字符的正则出来,所以想了个馊主意,用了个除了"\f"换页以外的所有字符再非贪婪匹配,因为在个源码内不可能换页吧,呵呵.
      

  6.   

    text44(text)的[^.](.*)也是OK的,呵呵,谢谢大家!