Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20400
| References | <CABicbJLzLM9As_Ji3EV3kZoV_5_OS129jnFdzZtbgBQTiNBDQA@mail.gmail.com> |
|---|---|
| Date | 2012-02-14 16:05 +0100 |
| Subject | Re: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ? |
| From | Vlastimil Brom <vlastimil.brom@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5801.1329231954.27778.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
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
csiph-web