Backreferences in python ?

Duncan Booth duncan.booth at invalid.invalid
Mon Jan 23 18:52:55 CET 2006


Pankaj wrote:

> Here problem is , i am not getting backreferences using \1 and \2
> 

You wrote:
>   subStrPattern1_hasInitialization = "\1"

"\1" is the way to create a string containing a control-A character. What 
you actually wanted was a string containing a backslash and a "1", so you 
need either:

    "\\1"

or

    r"\1"

Try using the print statement to see what all those strings you are 
creating actually contain.



More information about the Python-list mailing list