chho的专栏

对于整个世界我微不足道,但是我对于自己确是全部

原创 简明正则速查收藏

Simple:是不用区分大小写的和出现位置的
  • RE: soft
  • Match: Softleader, software, Javasoft, Microsoft, i2software
The period notation :用 "." 来替换一个字符
  • RE: s.o
  • Match: sso, soo, sto, s#o, s o
The bracket notation :用 "[]" 来限制替换的字符集来取代一个字符
  • RE: s[aeio]o
  • Match: sao, seo, sio, soo
The OR operator :用 "()" 来限制替换的字符集来取代数个字符, 用 "|" 分隔.
  • RE: s(aa|i|o)o
  • Match: saao, sio, soo
The quantifier notations : 用以下的方式限定出现的字符次数,"*":0 到多, "+": 1到多, "?": 0 到 1, "{n}":n个, "{n,m}": n到m个.
    电话:99-99999999
  • RE: [0-9]{2}\-[0-9]{8}
  • Match: 02-89519456 , 02-89519554
    电话:99-99999999 或 9999999999
  • RE: [0-9]{2}\-?[0-9]{8}
  • Match: 02-89519456 , 02-89519554 , 0289519999
    身份证字号: A999999999
  • RE: [A-Z]{1}[0-9]{9}
  • Match: A111111111, B123456789, Z987654321
The NOT notation :用 "^" 来禁止替换的字符来取代某个字符
  • RE: [^B]1
  • Match: A1
  • Not Match: A2,B1,B2
The parentheses and space notations :用 "\s" 来设置空白字符
    美国表示日期格式
  • RE: [a-z]+\s+[0-9]{1,2},\s*[0-9]{4}
  • Match: June 20, 2003
Other miscellaneous notations : 特殊的替换符号定义, 为了方便使用.
  • \d [0-9]
  • \D [^0-9]
  • \w [A-Z0-9]
  • \W [^A-Z0-9]
  • \s [ \t\n\r\f]
  • \S [^ \t\n\r\f]

发表于 @ 2004年12月11日 14:57:00

新一篇: unsaved-value的经典解释 | 旧一篇: 学习书籍的推荐

用户操作
[即时聊天] [发私信] [加为好友]
chho
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
chho的公告


名字:Chho
JAVA程序员,现在对Linux产生了浓厚的兴趣。

我的Mail:
文章分类
收藏
    存档
    软件项目交易
    Csdn Blog version 3.1a
    Copyright © chho