日常问:正则表达式里的加号(+)代表什么?

最近有被问到正则表达式里的加号代表什么含义,作为写正则表达式的时候临时查语法的老年开发者的我来说,决定开始记录一些平常遇到的问题。

What’s the meaning of plug sign in Regular Expression?

“When an ERE(Extended Regular Expressions) matching a single character or an ERE enclosed in parentheses is followed by the special character ( ‘+’ ), together with that it shall match what one or more consecutive occurrences of the ERE would match. For example, the ERE “b+(bc)” matches the fourth to seventh characters in the string “acabbbcde”. And, “[ab]+” and “[ab][ab]*” are equivalent.“[1]

所以代表的是匹配加号(+)之前的正则表达式1次或多次。

例如:
[0-9]+可以匹配一位以上的数字
[A-Z]+可以匹配一位以上的大写英文字符
(ABC)+则可以匹配连续的ABC字符串。
还有上述的
[ab]+和[ab][ab]*等价

参考文献:
[1] Regular Expression, IEEE Std 1003.1-2017, Open Group (2019/02/23) Retrieved http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值