泳裤王子不在
This is tclh123's second blog which is host by the lovely GAE. BTW, fuck the GFW.
rss
email
twitter
facebook
  • Home
  • <li class="page_item"><a href="/About" target="">About</a></li>

[笔记整理]Regular Expression / 正则表达式

0 Comments
Posted on 十一月 14 2012
<p><span style="font-style: italic;">2012.3.12笔记 by tclh123 - 自学版</span></p> <hr /> <p>&nbsp;</p> <h2>1、基本符号</h2> <table> <tbody> <tr> <th>符号</th> <th>名称</th> <th>匹配规则</th> </tr> <tr> <td>.</td> <td>单点</td> <td>除换行外任意字符</td> </tr> <tr> <td>*</td> <td>星号</td> <td>前面的匹配可以出线<span style="text-decoration: underline;">任意次</span></td> </tr> <tr> <td>+</td> <td>加号</td> <td>前面的匹配出线至少一次</td> </tr> <tr> <td>{n}</td> <td>大括号指定</td> <td>前面的匹配恰出现n次</td> </tr> <tr> <td>{n,m}</td> <td>大括号指定,拓展</td> <td>前面的匹配出现n~m次</td> </tr> <tr> <td>?</td> <td>问号</td> <td>匹配0次或1次</td> </tr> <tr> <td>[]</td> <td>方括号</td> <td>指定匹配集</td> </tr> <tr> <td>[^..]</td> <td>非</td> <td>取反集</td> </tr> <tr> <td>[ - ]</td> <td>连字符</td> <td>如,[0-9]、[a-z]</td> </tr> <tr> <td>()</td> <td>括号</td> <td>可以用来分组(,返回的第一组是所有匹配)</td> </tr> </tbody> </table> <h2><!--more--></h2> <h2>2、常见类型</h2> <ul> <li>\d = [0-9]</li> <li>\D = [^0-9]</li> <li>\w = [a-zA-Z0-9_]</li> <li>\W = [^a-zA-Z0-9_]</li> <li>\s = [\t\n\e\f]<span>,(空白字符)</span></li> <li>\S = [^\t\n\e\f]</li> </ul> <h2>3、关于限定符 *、+、?</h2> <p>默认是&ldquo;贪心的&rdquo;,即尽可能多匹配字符。在其后再加&ldquo;?&rdquo;,变为尽可能少匹配字符。</p> <h2>4、一般思路</h2> <p>把要匹配的东西替换为&ldquo;(.*?)&rdquo;,然后获得相应分组的信息即可。</p> <p>&nbsp;</p> <p>&nbsp;</p> --End--

Tags:  
Categories:

Leave a Reply

+=



About Me

    Harry Lee
    Student in Software Engineering
    [email protected], Zhejiang
    [email protected]Xidian University
    more...

Feeds

  • Entries (RSS)
  • Comments (RSS)
  • 订阅到 Google Reader
  • 订阅到 抓虾
  • 订阅到 鲜果
  • 订阅到 QQ

Popular Posts

  • Macbook pro 装 Ubuntu12.4 的BCM4331无线网卡驱动(9479)
  • rvm使用淘宝ruby镜像(6944)
  • [转载] Wordpress Rewrite / Permalink内部过程分析(6664)
  • XQuartz-2.7.3.dmg下载地址,x11 for mac...(6598)
  • wordpress multisite using subdomain/ iis + url rewrite module 2.0 / web.config(6513)
  • google app engine sdk directory on macos/osx(6291)
  • sublime text 2 for osx,build system,open terminal window(6076)
  • sublime text 2 for osx / python build system(5890)

Recent Posts

  • Use Octpress
  • rvm使用淘宝ruby镜像
  • [笔记整理]Regular Expression / 正则表达式
  • sublime text 2 for osx / python build system
  • wordpress multisite using subdomain/ iis + url rewrite module 2.0 / web.config
  • google app engine sdk directory on macos/osx
  • Macbook pro 装 Ubuntu12.4 的BCM4331无线网卡驱动
  • XQuartz-2.7.3.dmg下载地址,x11 for mac...

Recent Comments

Categories

Archives

Blog roll


  • Home
  • <li class="page_item"><a href="/About" target="">About</a></li>
  • Login
Powered by Google App Engine  |   Designed by WebTreats  |   由 xuming 提供 Micolog程序