Parsing HTML code with regex

From: Anthony Walsh
> Sent: Tuesday, October 24, 2006 12:35 PM
> I'm trying to count and print each <tr> and <tr 'something'>.

Do you just want to match the "<tr>", or do you want to match the
"<tr>...</tr>"?

Assuming the former:
row_tags = op_file.scan( /<tr[^>]+>/ )
p row_tags, row_tags.length

Er, oops. I mean /<tr[^>]*>/ of course, to match the no-attribute row as
well.

···

From: Gavin Kistner