1
正則元字符 描述
2
-----------------------------------------------------------------------
3
? 可以出現(xiàn)0次或1次,但至多出現(xiàn)1次
4
* 可以出現(xiàn)任意次,也可以不出現(xiàn)
5
+ 出現(xiàn)1次或多次,但至少出現(xiàn)1次
6
{n} 一定出現(xiàn)n次
7
{n,m} 至少出現(xiàn)n次,但至多不能超過m次
8
{n,} 可以出現(xiàn)任意次,但至少出現(xiàn)n次

2

3

4

5

6

7

8

例如:我們要去匹配以下字符串:
<input type=text/>
<input type=button />
<input type=password />
可以用下面的表達式:
1
<input +type *= *(button|text|password){1} */>

該表達的意思是:
以"<"開始緊接著是i->n->p->u->t->至少一個空格->t->y->p->e->任意個空格->=->任意個空格->一個button或者一個text或者一個password
->任意個空格->/最后以">"結(jié)束