Isn't re.findall supposed to find all?

Alex Martelli aleaxit at yahoo.com
Fri Nov 10 19:07:49 EST 2000


"June Kim" <junaftnoon at nospamplzyahoo.com> wrote in message
news:8uhv61$mbu$1 at news.nuri.net...
> >>> z='abcde[abcdefrdofhd]kdeioslkdfj[sdkfj]dkj'
> >>> p=re.compile('(\[.*\])')
> >>> result=re.findall(p,z)
> >>> result
> ['[abcdefrdofhd]kdeioslkdfj[sdkfj]']
> >>>
>
> I expected something like ;
> ['[abcdefrdofhd]','[sdkfj]']
>
> The chances are I've done something wrong, but can't
> tell what it is yet. What do you say?

Try re.compile(r'(\[[^\]]\])') ...


Alex






More information about the Python-list mailing list