Peter Hansen peter at
Fri Jan 10 21:18:15 CET 2003

read-the-signature at wrote:
> Peter Hansen <peter at> 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...


More information about the Python-list mailing list