Extracting text from a string

Anthra Norell anthra.norell at tiscalinet.ch
Thu Sep 7 17:18:47 EDT 2006


s = '''<span class="sale">
     $14.99
    </span>, <span class="sale">
     $27.99
    </span>, <span class="sale">
     $66.99
    </span>, <span class="sale">
     $129.99
    </span>, <span class="sale">
     $254.99
   </span>'''

>>> for line in [l.strip () for l in s.splitlines ()]:
          if line [0] == '$': print line

$14.99
$27.99
$66.99
$129.99
$254.99

Why parse? Why regular expressions? 

Frederic





More information about the Python-list mailing list