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.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
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 "
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
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
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
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
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 "
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
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
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
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
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.UNICODE|re.IG
Oof! That should be:
mp3entry = valign + number.setResultsName("number") + tdEnd + \
tdStart + SkipTo(aStart) + aStart + \
SkipTo(tdEnd).setResultsName("name") + tdEnd
--
http://mail.python.org/mailman/listinfo/python-list
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("
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
16 matches
Mail list logo