正则表达式必知必会

1.

{n} Exactly n of the preceding element. (只能匹配连续n个字符)

{n,} n or more of the preceding element.(可以匹配n,或任意大于n个连续字符。贪婪匹配,会尽量匹配多的字符)

{n,m} Between m and n of the preceding element.(可以匹配n到m个连续字符,贪婪匹配,连续m个字符比连续n个字符优先匹配)

{n,}?这个正则表达式,则属于懒惰型匹配,因为有了通配符‘?’,(匹配至少 n 个字符,而且越少越好. 其实结果与{n}是没差别的)

2.

 

posted @ 2016-06-02 07:46  Wcy100  阅读(141)  评论(0编辑  收藏  举报