Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   extracting text (http://www.velocityreviews.com/forums/t808724-extracting-text.html)

Dan 07-11-2003 11:46 AM

extracting text
 
I have a HTML table which I would like to extract text inside a <TD>. For an
example
<TD class=12>Some text</TD>

I can write a code that detects the beginning of TD...
print line ~= "<TD class12>"

But how do I make it stop at </TD>. In the code above, I just want to print
"Some text"

thanks



Dan 07-11-2003 07:40 PM

Re: extracting text
 
thank you
"Tim Hunter" <Tim.Hunter@sas.com> wrote in message
news:snstgv4pbjgohvs40b5nv5gn9hcdpl3s9c@4ax.com...
> Here's one answer to your question. Watch out, almost any change to
> the input will break it.
>
> irb(main):012:0> s = "<TD class=12>Some text</TD>"
> "<TD class=12>Some text</TD>"
> irb(main):013:0> m = %r{<TD [^>]+>([^<]+)</TD>}.match(s)
> #<MatchData:0x276f978>
> irb(main):014:0> p m[1]
> "Some text"
> nil
> irb(main):015:0>
>
> On Fri, 11 Jul 2003 07:46:44 -0400, "Dan" <falseflyboy@yahoo.comNONO>
> wrote:
>
> >I have a HTML table which I would like to extract text inside a <TD>. For

an
> >example
> ><TD class=12>Some text</TD>
> >
> >I can write a code that detects the beginning of TD...
> >print line ~= "<TD class12>"
> >
> >But how do I make it stop at </TD>. In the code above, I just want to

print
> >"Some text"
> >
> >thanks
> >

>





All times are GMT. The time now is 02:17 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.