* 和 + 正则表达式的区别 [英] Difference between * and + regex

查看:25
本文介绍了* 和 + 正则表达式的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我下面示例中 *+ 运算符之间的区别:

Can anybody tell me the difference between the * and + operators in the example below:

[<>]+ [<>]*

推荐答案

每个都是量词,星形量词(*) 表示前面的表达式可以匹配零次或多次,就像{0,} 而加号(+)表示前面的表达式必须至少匹配一次或多次并且与{1相同,} .

Each of them are quantifiers, the star quantifier(*) means that the preceding expression can match zero or more times it is like {0,} while the plus quantifier(+) indicate that the preceding expression MUST match at least one time or multiple times and it is the same as {1,} .

总结一下:

a*  ---> a{0,}  ---> Match a or aa or aaaaa or an empty string
a+  ---> a{1,}  ---> Match a or aa or aaaa but not a string empty

这篇关于* 和 + 正则表达式的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆