读书人

婚配一个(具体中文的)正则表达式

发布时间: 2011-12-14 23:20:17 作者: rapoo

匹配一个(具体中文的)正则表达式

HTML code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><meta http-equiv="content-type" content="text/html; charset=gb2312"><TITLE>【IP138】— 138查! http://www.IP138.Com/</TITLE><META content="IP138,IP地址查询,手机号码归属地,邮政编码,长途电话区号,身份证号码验证专业查询网" name="description"><META content="IP138,IP地址查询,手机号码归属地,邮政编码,长途电话区号,身份证号码验证查询,域名查询,whois查询" name="keywords"><STYLE type=text/css>A:link {    COLOR: #1c5f82; TEXT-DECORATION: none}A:visited {    COLOR: #1c5f82; TEXT-DECORATION: none}A:hover {    COLOR: #cc5533; TEXT-DECORATION: underline}A.red:link {    COLOR: #ff0000; TEXT-DECORATION: none}A.red:visited {    COLOR: #ff0000; TEXT-DECORATION: none}A.red:hover {    COLOR: #ff0000; TEXT-DECORATION: underline}.subt {    COLOR: #aa3333; FONT-FAMILY: "宋体"; FONT-SIZE: 9pt}.tdc {    COLOR: #333333; FONT-FAMILY: "宋体"; FONT-SIZE: 9pt}.tdc1 {    COLOR: #ffffff; FONT-FAMILY: "宋体"; FONT-SIZE: 9pt}.tdc2 {    COLOR: #008000; FONT-FAMILY: "宋体"; FONT-SIZE: 9pt}.bdtj {    BACKGROUND: #6699cc; BORDER-BOTTOM: #6699cc 1px solid; BORDER-LEFT: #6699cc 1px solid; BORDER-RIGHT: #6699cc 1px solid; BORDER-TOP: #6699cc 1px solid; COLOR: #ffffff; FONT-SIZE: 9pt; HEIGHT: 18px}BODY {    SCROLLBAR-HIGHLIGHT-COLOR: #f7f7f7; SCROLLBAR-SHADOW-COLOR: #f7f7f7; SCROLLBAR-ARROW-COLOR: #EFF1F3; SCROLLBAR-TRACK-COLOR: #EFF1F3; SCROLLBAR-BASE-COLOR: #f7f7f7}</STYLE><SCRIPT LANGUAGE="JavaScript"><!--    function resizeMe(){        window.focus();    }//--></script><SCRIPT LANGUAGE="JavaScript"><!--function checkMobile(){    var sMobile = document.mobileform.mobile.value    if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(sMobile))){        alert("不是完整的11位手机号或者正确的手机号前七位");        document.mobileform.mobile.focus();        return false;    }}//--></SCRIPT></HEAD><BODY leftmargin="1" topmargin="1" onload="javascript:resizeMe()"><CENTER><a href="http://www.ip138.com" target="_blank"><FONT class=tdc>手机号码归属地专业在线查询网</FONT></a></CENTER><HR SIZE=1 width=320><TABLE width=349 border=1 align="center" cellPadding=4 borderColor=#3366cc style="BORDER-COLLAPSE: collapse">    <FORM action="" method="get" name="mobileform" onsubmit="return checkMobile();">    <TR bgColor=#eff1f3 class=tdc>        <TD align=middle width=130 noswap>手机号码(段) </TD>        <TD align=middle width=*><INPUT class=tdc name="mobile" maxLength="11">        <INPUT name="action" type="hidden" value="mobile"> <INPUT class="bdtj" type="submit" value="查 询">        </TD>    </TR>    </FORM></TABLE><BR><TABLE width=349 border="1" align="center" cellpadding="4" bordercolor=#3366cc style="border-collapse: collapse">    <TR>        <TD colspan=2 class=tdc1 align=center height=24 bgcolor=#6699cc>++ ip138.com查询结果 ++</TD>    </TR>    <TR class=tdc bgcolor=#EFF1F3>        <TD width="130" align="center" noswap>您查询的手机号码段</TD>        <TD width=* align="center" class=tdc2>1387900</TD>    </TR>    [color=#FF0000]<TR class=tdc bgcolor=#EFF1F3>        <TD align="center">卡号归属地</td><!-- <td width="130" align="center">卡号归属地</TD> --> <TD class="tdc2" align="center">江西 新余</TD>    </TR[/color]>    <TR class=tdc bgcolor=#EFF1F3><!-- <td width="130" align="center" noswap></td> --><TD width="130" align="center" noswap>卡 类 型</td><td align="center" class='tdc2'>移动全球通卡</TD>    </TR>    <TR class=tdc bgcolor=#EFF1F3>        <TD align="center">区 号</TD><!-- <td></td> --><TD align="center" class=tdc2>0790</TD>    </TR>    <TR class=tdc bgcolor=#EFF1F3>        <TD align="center">邮 编</TD>        <TD align="center" class=tdc2>336600 <a href="http://alexa.ip138.com/post/" target="_blank">更详细的..</a></TD></TR></TABLE><br/><center><iframe src="/jss/bd_460x60.htm" frameborder="no" width="460" height="60" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></center><CENTER><p align="center"><a href="http://www.3533.com/phone/" target="_blank"><font color="#008000">手机大全</font></a>.<a href="http://game.3533.com/game/" target="_blank"><strong><font color="#008000">手机游戏</font></strong></a>.<a href="http://game.3533.com/zhuti/" target="_blank"><font color="#008000">手机主题</font></a>.<a href="http://game.3533.com/ringmp3sort/" target="_blank"><font color="#008000">MP3手机铃声</font></a>.<a href="http://game.3533.com/ruanjian/" target="_blank"><font color="#008000">手机软件</font></a>.<a href="http://you.3533.com/" target="_blank"><strong><font color="#008000">手机网游</font></strong></a></p><p align="center"><a href="http://qq.3533.com:8080/book.asp?siteid=9&no=1387900" target="_blank">如发现手机号码所在地数据不对.请按此留言.谢谢</a></p><p align="center">手机WAP上网查询手机号地址 wap.ip138.com 用手机随时可以查</p><p align="center"><a href="http://www.ip138.com/sjlink.htm" target="_blank">欢迎各网站免费链接本站手机号码查询系统,获取代码按此</a></p></BODY></HTML> 


匹配红色字的那一段的正则表达式

[解决办法]
是我太弱智了么,匹配红色字??、上面这么多红色字。。。。
[解决办法]
这要匹配到何年何月
[解决办法]
啊,这正则可以么,不行的话解析XML的方式呢
[解决办法]
怎么匹配 相等匹配还用正则么
干么用程序抓数据 还是改静态页面
根据需要写
[解决办法]
解析html吧

也有相关的类包

应该比正这快
[解决办法]
使用jsoup解析html,jquery-like selector 选择 tag。
从ip138查询手机号:

Java code
Document doc = Jsoup.connect("http://www.ip138.com:8080/search.asp").data("action","mobile").data("mobile","1387900").userAgent("Mozilla").timeout(3000).post();Element node = doc.select("tr.tdc:eq(2)").first();String s1 = node.select("td:eq(0)").first().text(); //卡号归属地String s2 = node.select("td:eq(1)").first().text(); // 江西 新余
[解决办法]
解析网页,正则不是最方便的。

读书人网 >J2SE开发

热点推荐