... Foo, Bar, Wibble A, B, C2, N, J, Baz, 开发者_如何学PythonQux, More, More, ...
... Bar, Qux, Wibble D, E, J, N6, O, Foo, Foo, More, More, ... and so on
How do I match highlighted part of these strings using PERL-compatible regular expressions?
It starts with a word "Wibble" and continues with one or two character components separated by a comma until next word.
From what I can tell, this may work for you:
/Wibble( [A-Z]\d?,)*/
I would try:
/(Wibble(?:\s[A-Z0-9]{1,2},)+)/
/Wibble((?:\s+[A-Z0-9]{1,2},)*)/
check $1
.
of course, when you say uppercase and then have numbers in your example, some exceptions have to be made.
not-at-all-serious answer: /(Wibble A, B, C2, N, J,)/
精彩评论