[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: parsing HTML code with regex

Gavin Kistner

10/24/2006 6:48:00 PM

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


>
> 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-....
>
>