您的位置:首页 > 其它

正则表达式相关内容

2009-10-17 15:58 225 查看
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->

正则表达式(

Regular Expression




是一种生成字符串的字符串


是一门语言


是一些字符串的模式


用于字符串查找、匹配、指定字符串替换、字符串分割等


正则表达式之限定符


"ab*"
=ab{0,}


能匹配

a



ab



abb



abbb

……,

*

表示前面单个字符可以有零次或多次


"ab+"
=ab{1,}

+

前面单个字符一次或多次


"or?"
=or{0,1}


能匹配

o



or



?


表示前面字符可以有零次或一次


x{n}


正好

n

次(

n>0




x{n,m}


最少

n

次至最多

m




x{n,}


最少

n



,


[
]


仅仅匹配方括号其中的字符


()


分组,圆括号中的字符视为一个整体。


连字符

-


表示一个范围。

[0-9a-fA-F]


使用连字号


(



)

允许指定连续字符范围。


“否”符号

^


表示不希望被匹配的字符(排除)


“或”符号


|



/



转义字符




Java

中,必须对每一个向前的斜杠(“

/

”)进行转义处理




//

”表示

"

/

"

,“

//

”表示

"

/

"


正则表达式之字符类


/d

=[0-9]


/D

=[^0-9]


/w

=[A-Za-z0-9]

及下划线

_


/W

=[^A-Za-z0-9]


/s

=[/t/n/r/f]


任何空白字符


/S

=[^/f/n/r/t/v]


^


指定匹配必须出现在字符串的开头


$


指定匹配必须出现在以下位置



字符串结尾、字符串结尾的

/n

之前或行的结尾。

doc

结尾

--doc$
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: