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

Vinay Sajip vinay_sajip at yahoo.co.uk
Tue Feb 14 08:20:48 EST 2012


On Feb 14, 4:38 am, Devin Jeanpierre <jeanpierr... at gmail.com> wrote:
> 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

$ is a meta character for regular expressions. Use '\$*', which does
compile.

Regards,

Vinay Sajip



More information about the Python-list mailing list