From: Mark Thomas Date: 2009-02-12T06:04:00+09:00 Subject: Re: regexp problem On Feb 11, 3:36 pm, w_a_x_...@yahoo.com wrote: > On Feb 11, 11:01 am, Mark Thomas wrote: > > > As long as we're being pedagogical, I prefer XPath to all the previous > > posted solutions. > > > * More accommodating to minor changes in the HTML > > * Very short (one-liner) and easy to read (IMHO) > > > require 'nokogiri' > > doc = Nokogiri::HTML(html) > > > puts doc.xpath('//td[contains(.,"Traffic left")]/following- > > sibling::td//script').to_s.scan(/Math.ceil.-(\d*)/) > > What if the cell contains "No Traffic left"? Then you can use the XPath function starts-with() instead of contains ().