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

D

Devin Jeanpierre

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
 
V

Vinay Sajip

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
 
D

Devin Jeanpierre

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

I mean for it to be a meta-character.

I'm wondering why it's OK for to repeat a zero-width match if it is a
zero-width assertion.

-- Devin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top