is this a known re 'bug/feature'?

Fredrik Lundh fredrik at effbot.org
Mon Jan 15 12:20:00 EST 2001


Robin Becker wrote:
> I find the following bug/feature/difference between the new and
> older re modules, is this a known feature?  Seems like the new re
> doesn't like {m,n} modifiers.
>
> >>> import re, pre
> >>> P = re.compile('\\{(M{1,5}|YYYY|YY|D{1,4})\\}',re.MULTILINE|re.IGNORECASE)
> >>> oP = pre.compile('\\{(M{1,5}|YYYY|YY|D{1,4})\\}',re.MULTILINE|re.IGNORECASE)

note that the flag values differ between SRE and PCRE, so
you should make sure to use flags from the right module...

(not that it seems to matter in this case)

> >>> P.match('{MMMMM}')
> >>> oP.match('{MMMMM}')
> <pre.MatchObject instance at 0113B754
> >>>>

there is definitely a bug hiding in here, but I'm not sure it's
related to the {m,n} syntax -- the "re" version works if you
remove the IGNORECASE flag (!?).

I'll investigate.

(In the meantime, feel free to post this bug report to the
SF bug tracker).

Thanks /F





More information about the Python-list mailing list