首页
论坛
图书
开发资料
在线文档
网址
下载
联系我们
 新闻│Java│JavaScript│Eclipse│Eclipse 英文│J2EE│J2ME│J2SE│JSP│Netbeans│Hibernate│JBuilder│Spring│Struts
站内搜索: 请输入搜索关键词

当前页面: 开发资料首页 → Java 专题 → 简明正则速查

简明正则速查

摘要: 简明正则速查

</td> </tr> <tr> <td width="509" height="35" valign="top" class="ArticleTeitle"> 简明正则速查

1、Simple:是不用区分大小写的和出现位置的
RE(正则表达式): soft
Match(匹配): Softleader, software, Javasoft, Microsoft, i2software

2、The period notation :用 "." 来替换一个字符
RE: s.o
Match: sso, soo, sto, s#o, s o

3、The bracket notation :用 "[]" 来限制替换的字符集来取代一个字符
RE: s[aeio]o
Match: sao, seo, sio, soo

4、The OR operator :用 "()" 来限制替换的字符集来取代数个字符, 用 "|" 分隔.
RE: s(aa|i|o)o
Match: saao, sio, soo

5、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

6、The NOT notation :用 "^" 来禁止替换的字符来取代某个字符
RE: [^B]1
Match: A1

7、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

8、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]
function TempSave(ElementID) { CommentsPersistDiv.setAttribute("CommentContent",document.getElementById(ElementID).value); CommentsPersistDiv.save("CommentXMLStore"); } function Restore(ElementID) { CommentsPersistDiv.load("CommentXMLStore"); document.getElementById(ElementID).value=CommentsPersistDiv.getAttribute("CommentContent"); } </td> <td width="175" valign="top" class="ArticleTeitle">
</td> </tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle">


↑返回目录
前一篇: 如何用java启动windows命令行程序
后一篇: 从XML中加载属性

首页 | 全站 Sitemap | 联系我们 | 设为首页 | 收藏本站
版权所有 Copyright © 2006-2007, Java 编程资料牛鼻站, All rights reserved