<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Doctor's WebLog]]></title> 
<link>http://www.gaobo.info/index.php</link> 
<description><![CDATA[博乐的自留地]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Doctor's WebLog]]></copyright>
<item>
<link>http://www.gaobo.info/read.php/611.htm</link>
<title><![CDATA[匹配域名的正则表达式]]></title> 
<author>Doctor &lt;gregry@cqut.edu.cn&gt;</author>
<category><![CDATA[PHP&amp;DB&amp;...]]></category>
<pubDate>Tue, 02 Jun 2009 00:58:49 +0000</pubDate> 
<guid>http://www.gaobo.info/read.php/611.htm</guid> 
<description>
<![CDATA[ 
	昨天搞了IPv4的正则，今天又需要域名的，我汗……<br/>干脆直接去Regular Expression Library找算了，合格的如下：<br/><div class="code">^&#91;a-zA-Z0-9&#93;+(&#91;a-zA-Z0-9&#92;-&#92;.&#93;+)?&#92;.(aero&#124;biz&#124;com&#124;coop&#124;edu&#124;gov&#124;info&#124;int&#124;mil&#124;museum&#124;name&#124;net&#124;org&#124;ac&#124;ad&#124;ae&#124;af&#124;ag&#124;ai&#124;al&#124;am&#124;an&#124;ao&#124;aq&#124;ar&#124;as&#124;at&#124;au&#124;aw&#124;az&#124;ba&#124;bb&#124;bd&#124;be&#124;bf&#124;bg&#124;bh&#124;bi&#124;bj&#124;bm&#124;bn&#124;bo&#124;br&#124;bs&#124;bt&#124;bv&#124;bw&#124;by&#124;bz&#124;ca&#124;cc&#124;cd&#124;cf&#124;cg&#124;ch&#124;ci&#124;ck&#124;cl&#124;cm&#124;cn&#124;co&#124;cr&#124;cs&#124;cu&#124;cv&#124;cx&#124;cy&#124;cz&#124;de&#124;dj&#124;dk&#124;dm&#124;do&#124;dz&#124;ec&#124;ee&#124;eg&#124;eh&#124;er&#124;es&#124;et&#124;fi&#124;fj&#124;fk&#124;fm&#124;fo&#124;fr&#124;ga&#124;gb&#124;gd&#124;ge&#124;gf&#124;gg&#124;gh&#124;gi&#124;gl&#124;gm&#124;gn&#124;gp&#124;gq&#124;gr&#124;gs&#124;gt&#124;gu&#124;gw&#124;gy&#124;hk&#124;hm&#124;hn&#124;hr&#124;ht&#124;hu&#124;id&#124;ie&#124;il&#124;im&#124;in&#124;io&#124;iq&#124;ir&#124;is&#124;it&#124;je&#124;jm&#124;jo&#124;jp&#124;ke&#124;kg&#124;kh&#124;ki&#124;km&#124;kn&#124;kp&#124;kr&#124;kw&#124;ky&#124;kz&#124;la&#124;lb&#124;lc&#124;li&#124;lk&#124;lr&#124;ls&#124;lt&#124;lu&#124;lv&#124;ly&#124; ma&#124;mc&#124;md&#124;mg&#124;mh&#124;mk&#124;ml&#124;mm&#124;mn&#124;mo&#124;mp&#124;mq&#124;mr&#124;ms&#124;mt&#124;mu&#124;mv&#124;mw&#124;mx&#124;my&#124;mz&#124;na&#124;nc&#124;ne&#124;nf&#124;ng&#124;ni&#124;nl&#124;no&#124;np&#124;nr&#124;nu&#124;nz&#124;om&#124;pa&#124;pe&#124;pf&#124;pg&#124;ph&#124;pk&#124; pl&#124;pm&#124;pn&#124;pr&#124;ps&#124;pt&#124;pw&#124;py&#124;qa&#124;re&#124;ro&#124;ru&#124;rw&#124;sa&#124;sb&#124;sc&#124;sd&#124;se&#124;sg&#124;sh&#124;si&#124;sj&#124;sk&#124;sl&#124;sm&#124;sn&#124;so&#124;sr&#124; st&#124;su&#124;sv&#124;sy&#124;sz&#124;tc&#124;td&#124;tf&#124;tg&#124;th&#124;tj&#124;tk&#124;tm&#124;tn&#124;to&#124;tp&#124;tr&#124;tt&#124;tv&#124;tw&#124;tz&#124;ua&#124;ug&#124;uk&#124;um&#124;us&#124;uy&#124;uz&#124;va&#124;vc&#124;ve&#124;vg&#124;vi&#124;vn&#124;vu&#124;wf&#124;ws&#124;ye&#124;yt&#124;yu&#124;za&#124;zm&#124;zr&#124;zw&#124;AERO&#124;BIZ&#124;COM&#124;COOP&#124;EDU&#124;GOV&#124;INFO&#124;INT&#124;MIL&#124;MUSEUM&#124;NAME&#124;NET&#124;ORG&#124;AC&#124;<br/></div><br/>描述：Based of from Steward Haddock's domain nam Checks domain names. This is an attempt to deal with some of the issues of the other reg ex in not handling leading periods(.), hypens(-). and valid extension.<br/>匹配：mydomain.com &#124; my-domain.info &#124; mydomain.aero<br/>不匹配：-mydomain.com &#124; mydomain.aaa &#124; .mydomain.com<br/><br/><div class="code">^(&#91;a-zA-Z0-9&#93;(&#91;a-zA-Z0-9&#92;-&#93;&#123;0,61&#125;&#91;a-zA-Z0-9&#93;)?&#92;.)+&#91;a-zA-Z&#93;&#123;2,6&#125;$</div><br/>描述：Checks domain names. This validates domains based on latest specifications (RFCs 952 and 1123 dealing with hostnames and RFC 1035 dealing with domain name system requirements) except that it only includes realistic fully-qualified domains: 1. requires at least one subdomain 2. allows shortest top-level domains like &quot;ca&quot;, and &quot;museum&quot; as longest. Other validation rules: 1. Labels/parts should be seperated by period. 2. Each label/part has maximum of 63 characters. 3. First and last character of label must be alphanumeric, other characters alphanumeric or hyphen. 4. Does not check maxlength of domain which incidentally is 253 characters of text (255 binary representation). For a regular expression that matches ALL domains: ^([a-zA-Z0-9]([a-zA-Z0-9&#92;-]&#123;0,61&#125;[a-zA-Z0-9])?&#92;.)*[a-zA-Z0-9]([a-zA-Z0-9&#92;-]&#123;0,61&#125;[a-zA-Z0-9])?$<br/>匹配：regexlib.com &#124; this.is.a.museum &#124; 3com.com<br/>不匹配：notadomain-.com &#124; helloworld.c &#124; .oops.org<br/>Tags - <a href="http://www.gaobo.info/go.php/tags/%25E6%25AD%25A3%25E5%2588%2599/" rel="tag">正则</a> , <a href="http://www.gaobo.info/go.php/tags/regular/" rel="tag">regular</a> , <a href="http://www.gaobo.info/go.php/tags/expression/" rel="tag">expression</a> , <a href="http://www.gaobo.info/go.php/tags/%25E8%25A1%25A8%25E8%25BE%25BE%25E5%25BC%258F/" rel="tag">表达式</a> , <a href="http://www.gaobo.info/go.php/tags/%25E5%259F%259F%25E5%2590%258D/" rel="tag">域名</a> , <a href="http://www.gaobo.info/go.php/tags/%25E6%25A8%25A1%25E5%25BC%258F/" rel="tag">模式</a>
]]>
</description>
</item><item>
<link>http://www.gaobo.info/read.php/611.htm#blogcomment2174</link>
<title><![CDATA[[评论] 匹配域名的正则表达式]]></title> 
<author>longines &lt;youscript@gmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 03 Jun 2009 02:32:56 +0000</pubDate> 
<guid>http://www.gaobo.info/read.php/611.htm#blogcomment2174</guid> 
<description>
<![CDATA[ 
	不错不错,比我自己写的好多了
]]>
</description>
</item>
</channel>
</rss>