regsub backreference question

William Park parkw at
Thu Apr 27 05:09:22 CEST 2000

On Thu, Apr 27, 2000 at 02:43:19AM +0000, Michael Esveldt wrote:
> I'm trying to figure out how back referencing works in python's regsub 
> module. I thought the following code would simply double the string 
> "foo" but it's just returning "foo".
> regsub.sub(r"(.*)", r"\1\1", "foo")
> What am I doing wrong here?

    regsub.sub(r"\(.*\)", r"\1\1", "foo")
    re.sub("(.*)", r"\1\1", "foo")


More information about the Python-list mailing list