a question on re
Marco Wahl
marco.wahl at gmail.com
Sat Apr 1 02:11:30 EST 2006
Hi,
> i tried to search 2 patterns
>
> pat1 = re.compile("blah")
> pat2 = re.compile("blah2")
>
>
> if i do
> if re.findall(pat1,something) and re.findall(pat2,something):
> do something
>
> if does not work
>
> but when i do a nest if,
>
> if re.findall(pat1,something) :
> if re.findall(pat2,something):
> do something
>
> it works..
>
> please advise on why the first code doesnt work.
it's not perfectly clear to me what you mean with 'doesnt work'.
The two if parts
> if re.findall(pat1,something) and re.findall(pat2,something):
> do something
and
> if re.findall(pat1,something) :
> if re.findall(pat2,something):
> do something
look equivalent to me. Could you please reveal your
value for text-string 'something'? Further I suggest
to replace the 'do something'-parts with 'print 42'.
Best wishes Marco
More information about the Python-list
mailing list