string stripping issues

Tim Williams (gmail) tdwdotnet at gmail.com
Fri Mar 3 09:43:30 CET 2006


On 3 Mar 2006 00:20:21 -0800, P Boy <prettyboy988-google at yahoo.com> wrote:
>
> This seems like a web page parsing question. Another approach can be as
> follows if you know the limiting token strings:
>
> a.split('    <TD WIDTH=175><FONT
> SIZE=2>')[1].split('</FONT></TD>\r\n')[0]



As others have mentioned , you really need a an HTML parser.   But the
following would work better than strip()

>>> a = '    <TD WIDTH=175><FONT SIZE=2>Hughes. John</FONT></TD>\r\n'
>>> a.replace('    <TD WIDTH=175><FONT SIZE=2>', '' )  #  '' = 2 single
quotes not 1 double quote
'Hughes. John</FONT></TD>\r\n'

HTH :)




--

Tim Williams
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060303/476622dc/attachment.html>


More information about the Python-list mailing list