Extract strings in python
Posted
by shadyabhi
on Stack Overflow
See other posts from Stack Overflow
or by shadyabhi
Published on 2010-03-17T17:38:02Z
Indexed on
2010/03/17
17:41 UTC
Read the original article
Hit count: 349
Basically, I want to extract the strings "AAA", "BBB", "CCC", "DDD" from a text file..
...... (other text goes here).....
<TD align="left" class=texttd><font class='textfont'>AAA</font></TD>
..... (useless text here).....
<TD align="left" class=texttd><font class='textfont'>BBB</font></TD>
....(more text).....
<TD align="left" class=texttd><font class='textfont'>CCC</font></TD>
<TD align="left" class=texttd><font class='textfont'>DDD</font></TD>
......(more text).....
I want something like if I do:-
data = foo("file.txt")
i get:-
data = ['AAA','BBB','CCC','DDD']
What is the best possible way? My file is not big..
© Stack Overflow or respective owner