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