正则表达式相关内容
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$
/* 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$
相关文章推荐
- 正则表达式及相关内容
- 正则表达式相关:C# RichTextBox显示html文本内容
- 正则表达式相关:C# RichTextBox显示html文本内容
- 正则表达式相关内容
- 正则表达式的相关内容。
- java正则表达式相关内容整理
- 正则表达式的相关内容
- 正则表达式相关:正则表达式处理html内容
- 正则表达式相关:正则表达式处理html内容
- python爬虫主要就是五个模块:爬虫启动入口模块,URL管理器存放已经爬虫的URL和待爬虫URL列表,html下载器,html解析器,html输出器 同时可以掌握到urllib2的使用、bs4(BeautifulSoup)页面解析器、re正则表达式、urlparse、python基础知识回顾(set集合操作)等相关内容。
- 正则表达式相关:正则表达式处理html内容
- 正则表达式相关:C# RichTextBox显示html文本内容
- 正则表达式相关图书推荐
- JS 正则表达式的相关方法(正则学习笔记1)
- 正则表达式重要识记内容
- jmeter正则表达式提取器相关操作讲解
- Javascript 正则表达式 要求内容不能为空(中文,字母,数字组成)
- 正则表达式相关:收录常用的正则表达式
- 使用正则表达式批量删除注释内容
- 数据库相关资料:常用的正则表达式操作符