re.sub() problem (regular expression)

Discussion in 'Python' started by Davy, Dec 14, 2007.

  1. Davy

    Davy Guest

    Hi all,

    I have read a re.sub() that confused me.

    s = 'P & Q'
    s = re.sub(r'([a-zA-Z0-9_.]+)', r'Expr("\1")', s)

    What's "\1" and the whole re.sub() mean?

    Best regards,
    Davy
     
    Davy, Dec 14, 2007
    #1
    1. Advertising

  2. Davy

    Rick Dooling Guest

    Rick Dooling, Dec 14, 2007
    #2
    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. VSK
    Replies:
    2
    Views:
    2,381
  2. Frank Wallingford

    Sub-sub-expression evaluation order

    Frank Wallingford, Dec 9, 2004, in forum: C Programming
    Replies:
    4
    Views:
    356
    Chris Torek
    Dec 10, 2004
  3. Ben
    Replies:
    2
    Views:
    954
  4. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    2,165
    Lawrence D'Oliveiro
    May 20, 2011
  5. Dave Roberts

    Ruby Sub Regular Expression

    Dave Roberts, Nov 12, 2008, in forum: Ruby
    Replies:
    7
    Views:
    139
    Jim McKerchar
    Nov 14, 2008
Loading...

Share This Page