[Tutor] simple regex question

Alan Gauld alan.gauld at yahoo.co.uk
Sun May 1 14:24:09 EDT 2016


On 01/05/16 17:49, bruce wrote:
> Hi. I have a chunk of text code, which has multiple lines.

>   s='''
> <td valign="top" colspan="1"><b><a href="#"
> id='CourseId10795788|ACCT2081|002_005_006' style="font-weight:bold;"
> onclick='ShowSeats(this);return false;' alt="Click for Class Availability"
> title="Click for Class Availability">ACCT2081</a></b></td>'''

That looks like HTML. regex won't work reliably on HTML.
You would be better using an HTML parser like BeautifulSoup
or even the standard library's html.parser(Python v3).
That will give more precise and reliable results for only
a little more effort.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list