Best Way to extract Numbers from String

Novocastrian_Nomad gregory.j.baker at gmail.com
Sat Mar 20 23:37:53 EDT 2010


Regular expression are very powerful, and I use them  a lot in my
paying job (unfortunately not with Python).  You are however,
basically using a second programing language, which can be difficult
to master.

Does this give you the desired result?

import re

matches = re.findall('<td>([\d\.,]+)\s*</td>', code)
for match in matches:
    print match

resulting in this output:
43.150
43.200
43.130
43.290
43.100
7,450,447



More information about the Python-list mailing list