How can I exclude a word by using re?

could ildg could.net at gmail.com
Sun Aug 14 11:26:09 EDT 2005


Thank you.
But what should I do if there are more than one hello and I only want
to extract what's before the first "hello". For example, the raw
string is "hi, how are you? hello I'm fine, thank you hello. that's it
hello", I want to extract all the stuff before the first hello?

On 14 Aug 2005 08:02:16 -0700, Christoph Rackwitz
<christoph.rackwitz at gmail.com> wrote:
> re.findall('(.*)hello|(.*)', 'hi, how are you. hello')
> re.findall('(.*)hello|(.*)', 'hi, how are you. ello')
> take a look at the outputs of these.
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list