backreference
John Machin
sjmachin at lexicon.net
Sun Jan 12 06:57:34 EST 2003
read-the-signature at send-spam-to-dev-null.com wrote in message news:<avn96u$nlb$1 at wnnews.sci.kun.nl>...
> 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 :-)
>
What will happen if the 6,000 documents contain commas like in this sentence?
What if they contain some source code e.g. ",".join(some_list)??
More information about the Python-list
mailing list