Regular Expression problem

vmilitaru at sympatico.ca vmilitaru at sympatico.ca
Thu Sep 14 08:00:14 EDT 2000


Greetings. I am posting this in the hope that it will somehow end up on comp.lang.python.
I am using Python2b and can't get over the following RE problem:

myregexx = re.compile(r'Table Name(\W+)', re.IGNORECASE)
ssss = re.sub( myregexx , r'."""\nclass \1 (base_class):\n"""', ttt)

I basically want to re-use the word matched with (\W+) as part of the output. In Perl, I'd use the $1 variable.
In Perl, I'd use the $1 variable. My initial understanding was that \1 is the Py equivalent.
But since this obviously doesn't seem to be the case, and re-reading the on-line docs for the 100th time doesn't seem to help anymore, could somebody put me on the right track here.

Regards,
vio





More information about the Python-list mailing list