Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20400 > unrolled thread

Re: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ?

Started byVlastimil Brom <vlastimil.brom@gmail.com>
First post2012-02-14 16:05 +0100
Last post2012-02-14 16:05 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? Vlastimil Brom <vlastimil.brom@gmail.com> - 2012-02-14 16:05 +0100

#20400 — Re: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ?

FromVlastimil Brom <vlastimil.brom@gmail.com>
Date2012-02-14 16:05 +0100
SubjectRe: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ?
Message-ID<mailman.5801.1329231954.27778.python-list@python.org>
2012/2/14 Devin Jeanpierre <jeanpierreda@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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web