Where can be a problem?

Peter Otten __peter__ at web.de
Fri Aug 12 03:06:32 EDT 2005


Lad wrote:

> I use the following
> ###############
> import re
> Results=[]
> data1='<a href="detailaspxmember=15015&mode=advert" </a><a
> href="detailaspxmember=15016&mode=advert" </a><a
> href="detailaspxmember=15017&mode=advert" </a>'
> ID = re.compile(r'^.*=(\d+)&.*$',re.MULTILINE)
> Results=re.findall(ID,data1)
> print Results
> #############
> to extract from data1 all numbers such as 15015,15016,15017
> 
> But the program extracts only the last number 15017.
> Why?
> Thank you for help
> La.

After changing 

data = '...
'

to 

data = '''...
'''

I get all three numbers. There is probably another significant difference
between the posted code and the code you are actually running.

Peter




More information about the Python-list mailing list