Parsing HTML code with regex

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

···

From: Anthony Walsh

I haven't even gotten to counting my matches. I'm still working on
matching with <tr> or <tr 'anything'>

I've done:

op_file = HTML_CODE
if op_file =~ /(<tr(.*?)>)+/

but it catches everything on from the first <tr to the end of
the line.
Any ideas?

-Shinkaku

--
Posted via http://www.ruby-forum.com/\.