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

Discussion in 'Python' started by Devin Jeanpierre, Feb 14, 2012.

  1. 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
     
    Devin Jeanpierre, Feb 14, 2012
    #1
    1. Advertising

  2. Devin Jeanpierre

    Vinay Sajip Guest

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

    On Feb 14, 4:38 am, Devin Jeanpierre <> 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
     
    Vinay Sajip, Feb 14, 2012
    #2
    1. Advertising

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

    On Tue, Feb 14, 2012 at 8:20 AM, Vinay Sajip <> wrote:
    > $ 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
     
    Devin Jeanpierre, Feb 14, 2012
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nevyn Twyll
    Replies:
    4
    Views:
    4,371
    Juan T. Llibre
    Mar 19, 2005
  2. Harald Armin Massa
    Replies:
    9
    Views:
    338
    Jeff Shannon
    Sep 29, 2004
  3. aspineux
    Replies:
    5
    Views:
    462
    Paddy
    Mar 30, 2007
  4. pjar09
    Replies:
    0
    Views:
    771
    pjar09
    Aug 11, 2010
  5. Tom Anderson

    Nothing to repeat

    Tom Anderson, Jan 9, 2011, in forum: Python
    Replies:
    4
    Views:
    1,318
    Terry Reedy
    Jan 9, 2011
Loading...

Share This Page