471,337 Members | 1,407 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

re.sub() problem (regular expression)

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,
Dec 14 '07 #1
1 1005
On Dec 13, 9:00 pm, Davy <zhushe...@gmail.comwrote:
What's "\1" and the whole re.sub() mean?
Read about backreferences here:


Also see the entry on parentheses here:



Dec 14 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Emhoff | last post: by
6 posts views Thread by Maurice LING | last post: by
4 posts views Thread by Buddy | last post: by
25 posts views Thread by Mike | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.