How can I exclude a word by using re?
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Sun Aug 14 16:44:43 EDT 2005
could ildg a écrit :
> 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".
Read The Fine Manual ?-)
> 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?
re.findall(r'^(.*)hello', your_string_full_of_hellos)
More information about the Python-list
mailing list