From: Peter Szinek Date: 2008-11-19T11:00:31+09:00 Subject: Re: ruby global regex question. --Apple-Mail-11--361408874 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit On 2008.11.19., at 1:06, knohr wrote: > For the life of me, i can't figure out a ruby equivalent to perl's /g > > basically, i want to do the following > > > while htmlSource=~m/(.*?)<\table>/g do > tableSource=$1 > tableSource=~m/Index (\d+)/ > indexNumber=$1 > > while tableSource=~m/(.*?)<\/tr>/g do > tableRowSource=$1 > doSomethingWith(tableRowSource, indexNumber) > end#while tableSource > > end#while htmlSource > > > I will actually need to pull multiple vars, not just a single one, > from the regex > I will need to do the outer loop an unknown amount of times per > document (0-20) and i will need to loop the inner an unknown amount of > times (0-29) > > > Thread safe would be a plus. > > > any suggestions? While I can't answer your original question, I could possibly help you with the scraping if you are willing to reveal the page you are trying to scrape and the data bits on it which should be scraped. Cheers, Peter ___ http://www.rubyrailways.com http://scrubyt.org --Apple-Mail-11--361408874--