Match any sequence which repeats itself n times
Do you know how to match a group which repeats itself n times? eg:
This is is is is a test [incl. the spaces between two 'is']
[incl. the spaces between two 'is']
F oo bar
T elel ephone: +49 1 88 /123 45 45 45
I tried the following regex pattern: (w+)1+
but it only matches two occurences of a group (and not n occurences)
Thank you very much
The problem with your pattern with respect to your sample input is that the pattern does not account for possible trailing spaces:
(w+s*)1+
Demo.
This is not universal, though: for example, this pattern will match "a ba ba ba ba b" as "a ba ba ba ba b", not as " a ba ba ba ba b ".
链接地址: http://www.djcxy.com/p/77014.html上一篇: 正则表达式匹配不是特定子字符串的东西
下一篇: 匹配任何重复n次的序列