regsub backreference question
William Park
parkw at freewwweb.com
Wed Apr 26 23:09:22 EDT 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?
Try
regsub.sub(r"\(.*\)", r"\1\1", "foo")
re.sub("(.*)", r"\1\1", "foo")
--William
More information about the Python-list
mailing list