Extracting text from a string

A

Anthra Norell

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
said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top