Isn't re.findall supposed to find all?
junaftnoon at nospamplzyahoo.com
Sat Nov 11 02:45:42 CET 2000
"June Kim" <junaftnoon at nospamplzyahoo.com> wrote in message
news:8ui0i5$nfc$1 at news.nuri.net...
> Well, I forgot the old rule "Longest match possible."
> It worked perfectly with this:
> >>> z
> >>> p=re.compile('\[[^\*\]')
> >>> re.findall(p,z)
> ['[abcdefrdofhd]', '[sdkfj]']
> But another problem emerged. What if the brackets were
> longer than one character? for example:
> z='this is yet another start of a sting end but never start an end'
> opening bracket : "start"
> closing bracket : "end"
> What I want to get is,
> re.findall(p,z) == ['[start of a string end]','[start an end]']
> How should I render the regular expression?
> Thanks in advance
I found out one way to do it! (bravo)
But my question still remains; I want to find a substring
that starts with a specific string, say XYZ and ends with
another specific string, say QPR, but hasn't got a string,
LMN in between the opener and the closer.
e.g. XYZ....(any length of letters but no LMN here).....QPR
Could any one enlighten me kindly?
More information about the Python-list