From: Peter Szinek Date: 2008-11-11T22:50:14+09:00 Subject: Re: using regular expressions... On 2008.11.11., at 14:22, soldier.coder wrote: > I have the following code: > > require 'open-uri' > def scrape_table(html) > %r{(.*?)}m =~html > $1 > end > > def scrape_case(a_line) > %r{(\d{6}-\d{2}<\/a>)}m =~ a_line > $1 > end > Is there any way I can grab all those links into an array? Sure - String#scan is your friend: def scrape_case(a_line) a_line.scan(/\d{6}-\d{2}<\/a>/) end ex: >> "123456-78 here is another: 111111-99".scan(/\d{6}-\d{2}< \/a>/) => ["123456-78", "111111-99"] HTH, Peter