backreference
Peter Hansen
peter at engcorp.com
Fri Jan 10 15:18:15 EST 2003
read-the-signature at send-spam-to-dev-null.com wrote:
>
> Peter Hansen <peter at engcorp.com> wrote:
> > Does something like this help?
> >
> >>>> re.sub(r'([^,?])(([,?]))', r'\1 \2', 'Hello, how are you?')
> > 'Hello , how are you ?'
Oops... I seem to have an extra pair of parentheses around the second group...
artifact of my refactoring as I tried to get it to work. You don't need
the (([,?])) there, just ([,?]) I think...
-Peter
More information about the Python-list
mailing list