建站代码网

热门标签

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

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

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]*等价
X