re.sub() problem (regular expression)

Davy zhushenli at gmail.com
Thu Dec 13 22:00:19 EST 2007


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



More information about the Python-list mailing list