2012/2/14 Devin Jeanpierre <jeanpierr...@gmail.com>: > Hey Pythonistas, > > Consider the regular expression "$*". Compilation fails with the > exception, "sre_constants.error: nothing to repeat". > > Consider the regular expression "(?=$)*". As far as I know it is > equivalent. It does not fail to compile. > > Why the inconsistency? What's going on here? > > -- Devin > -- > http://mail.python.org/mailman/listinfo/python-list
Hi, I don't know the reason for the observed differences either (I can think of some optimisation issues etc.), but just wanted to mention some other similar patterns to your lookahaed: It seems, that groups (capturing or not capturing) also work ok: >>> re.findall("($)*", "abc") ['', '', '', ''] >>> re.findall("(?:$)*", "abc") ['', '', '', ''] However, is there any realistic usecase for repeated zero-width anchors? regards, vbr -- http://mail.python.org/mailman/listinfo/python-list