How can I exclude a word by using re?

2005-08-14 Thread could ildg
In re, the punctuation "^" can exclude a single character, but I want to exclude a whole word now. for example I have a string "hi, how are you. hello", I want to extract all the part before the world "hello", I can't use ".*[^hello]" because "^" only exclude single char "h" or "e" or "l" or "o". W

Re: How can I exclude a word by using re?

2005-08-14 Thread Christoph Rackwitz
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

Re: How can I exclude a word by using re?

2005-08-14 Thread Jeff Schwab
could ildg wrote: > In re, the punctuation "^" can exclude a single character, but I want > to exclude a whole word now. for example I have a string "hi, how are > you. hello", I want to extract all the part before the world "hello", > I can't use ".*[^hello]" because "^" only exclude single char "

Re: How can I exclude a word by using re?

2005-08-14 Thread could ildg
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

Re: How can I exclude a word by using re?

2005-08-14 Thread Bruno Desthuilliers
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 ex

Re: How can I exclude a word by using re?

2005-08-14 Thread Peter Otten
could ildg wrote: > 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? T

Re: How can I exclude a word by using re?

2005-08-15 Thread John Machin
Bruno Desthuilliers wrote: > 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, t

Re: How can I exclude a word by using re?

2005-08-15 Thread John Machin
could ildg wrote: > In re, the punctuation "^" can exclude a single character, but I want > to exclude a whole word now. for example I have a string "hi, how are > you. hello", I want to extract all the part before the world "hello", > I can't use ".*[^hello]" because "^" only exclude single char "

Re: How can I exclude a word by using re?

2005-08-15 Thread could ildg
I want to use re because I want to extract something from a html. It will be very complicated without using re. But while using re, I found that I must exlude a hole word "", certainly, there are many many "" in this html. My re is as below: _ r=re.comp

Re: How can I exclude a word by using re?

2005-08-15 Thread Jordan Rastrick
could ildg said: > I want to use re because I want to extract something from a html. It > will be very complicated without using re. But while using re, I > found that I must exlude a hole word "", certainly, there are > many many "" in this html. Actually, for properly processing html, you shou

Re: How can I exclude a word by using re?

2005-08-15 Thread Paul McGuire
Given the example re that you've been trying to get working, here is a pyparsing approach that might be more, um, approachable. Unfortunately, since I don't have the URL of the page you are working with, I'm unable to test this before posting. Good luck, -- Paul # getMP3s.py # get pyparsing at ht

Re: How can I exclude a word by using re?

2005-08-15 Thread could ildg
Thank you, you code using pyparsing works very well. Now I got the "number" and the "url". But I still want to get the "name". I'll turn to pyparsing and see how to get the "name" from the html. But I hope you can enlighten me for one more time since I'm not farmiliar with the pyparsing module. O

Re: How can I exclude a word by using re?

2005-08-16 Thread Paul McGuire
Just as with re you were using "?P" to assign the matching text to the variable "xxx", pyparsing allows you to associate a name with an element of your grammar using setResultsName. Here is your original re: r=re.compile(ur'valign=top>(?P­­\d{1,2})]*­>­\s{0,2}' ur'' ur'(?P.+)',re.UNICO­­DE|re.IG

Re: How can I exclude a word by using re?

2005-08-16 Thread Paul McGuire
Oof! That should be: mp3entry = valign + number.setResultsName("number"­­) + tdEnd + \ tdStart + SkipTo(aStart) + aStart + \ SkipTo(tdEnd).setResultsName("n­ame") + tdEnd -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I exclude a word by using re?

2005-08-16 Thread Paul McGuire
I just reviewed what the re "\s" signifies: whitespace. This is easy, pyparsing ignores all intervening whitespace by default. So mp3Entry simplfies to: mp3entry = valign + number.setResultsName("number"­­­) + tdEnd + \ tdStart + aStart + \ SkipTo(tdEnd).setResultsName("­

Re: How can I exclude a word by using re?

2005-08-16 Thread could ildg
Thanks for all of you~ I made it. Pyparsing is really nice. On 16 Aug 2005 11:33:48 -0700, Paul McGuire <[EMAIL PROTECTED]> wrote: > I just reviewed what the re "\s" signifies: whitespace. This is easy, > pyparsing ignores all intervening whitespace by default. So mp3Entry > simplfies to: > > m