简明正则速查

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]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值