Re: parsing HTML code with regex

From: Gavin K.

From: Anthony W.

Sent: Tuesday, October 24, 2006 12:35 PM
I’m trying to count and print each

and <tr ‘something’>.

Do you just want to match the “

”, or do you want to match the
“ …”?

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs