variable in regexp

Peter Enis peterenis at gmx.net
Sat Aug 30 13:20:15 EDT 2003


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






More information about the Python-list mailing list