backreference

read-the-signature at send-spam-to-dev-null.com read-the-signature at send-spam-to-dev-null.com
Fri Jan 10 21:07:58 CET 2003


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 ?'
 
actually, it does (after adding dot, exclamation mark and so on). Had to
re-read the code twice before getting it, though. I had never worked with
the '\#' (where # is a number) before. Thanks!

> Not really general-purpose, but it works on the example you gave and maybe
> that's as complex as you need...

Yeah it is. Let's hope it runs relatively fast. I don't mind waiting a
little, but it has to run over about 6000 documents :-)

    Woohoo, time to run some experiments!

        Yours

            Bas

-- 
b a s {dot} v a n g i l s {at} c s {dot} k u n {dot} n l
BOFH excuse #356:
the daemons! the daemons! the terrible daemons!




More information about the Python-list mailing list