variable in regexp

Discussion in 'Python' started by Peter Enis, Aug 30, 2003.

  1. Peter Enis

    Peter Enis Guest

    hello,

    does anyone know how to use variables in regular expressions?

    var = '%%bob%%'

    replace = 'bob'

    var = re.sub("%%[^%%]*replace%%', 'peter', var)

    how do i have to mask the replace-variable?

    thanx
    Peter Enis, Aug 30, 2003
    #1
    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. Greg Hurrell
    Replies:
    4
    Views:
    149
    James Edward Gray II
    Feb 14, 2007
  2. Mikel Lindsaar
    Replies:
    0
    Views:
    463
    Mikel Lindsaar
    Mar 31, 2008
  3. Joao Silva
    Replies:
    16
    Views:
    339
    7stud --
    Aug 21, 2009
  4. Uldis  Bojars
    Replies:
    2
    Views:
    185
    Janwillem Borleffs
    Dec 17, 2006
  5. Matìj Cepl

    new RegExp().test() or just RegExp().test()

    Matìj Cepl, Nov 24, 2009, in forum: Javascript
    Replies:
    3
    Views:
    169
    Matěj Cepl
    Nov 24, 2009
Loading...

Share This Page