[Tutor] Printing regular expression match
Srinivas Iyyer
srini_iyyer_bio at yahoo.com
Sun Dec 4 00:55:03 CET 2005
Dear group,
I have two lists:
>>> a
['apple', 'boy', 'boy', 'apple']
>>> b
['Apple', 'BOY', 'APPLE-231']
>>> for i in a:
pat = re.compile(i,re.IGNORECASE)
for m in b:
if pat.match(m):
print m
Apple
APPLE-231
BOY
BOY
Apple
APPLE-231
>>>
Here I tried to match element in list a to element in
list b
and asked to ignore the case. It did work.
However, I do not know how to make it print only m
What I want :
Apple
BOY
APPLE-231
I do not want python to print both elenents from lists
a and b.
I just want only the elements in the list B.
how can i do that..
Please help me. thank you.
srini
__________________________________________
Yahoo! DSL Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com
More information about the Tutor
mailing list