How to write this repeat matching?

Ian Kelly ian.g.kelly at gmail.com
Mon Jul 7 18:18:34 CEST 2014


On Mon, Jul 7, 2014 at 7:30 AM,  <rxjwg98 at gmail.com> wrote:
> Because I am new to Python, I may not describe the question clearly. Could you
> read the original problem on web:
>
> https://docs.python.org/2/howto/regex.html
>
> It says that it gets 'abcb'. Could you explain it to me? Thanks again

The string being matched in the explanation at that link is 'abcbd',
not 'abcdb'. The 'a' in the pattern matches the 'a' in the string, the
'[bcd]*' in the pattern matches the 'bc' in the string (with a repeat
count of 2), and finally the 'b' in the pattern matches the 'b'
following that in the string.



More information about the Python-list mailing list