[Tutor] substituting with a group

Paul Tremblay phthenry@earthlink.net
Mon, 8 Jul 2002 17:56:10 -0400


On Mon, Jul 08, 2002 at 01:04:37AM -0700, Danny Yoo wrote:
> From: Danny Yoo <dyoo@hkn.eecs.berkeley.edu>
>
> Instead of using "$1", Python's regular expression engine uses '\1'
> instead.  So you can do something like:
> 
> ###
> >>> re.sub(r'(\w+) (\w+)', r'\2 \1', 'hello world this is a test')
> 'world hello is this test a'
> ###
> 
> 
> Hope this helps!
> 

Yes! (The previous post was also helpful.)

Thanks

Paul

-- 

************************
*Paul Tremblay         *
*phthenry@earthlink.net*
************************