From: Austin Ziegler Date: 2004-08-18T05:25:21+09:00 Subject: Re: multiple regexp matches This should do what you want. -austin str = ' ... ' re = /(<(\/?)span>)/i str.scan(re) # => [["", ""], ["", "/"], ["", "/"]] matches = [] str.scan(re) do matches << Regexp.last_match end matches.each do |match| match.captures.each_with_index do |capture, ii| soff, eoff = match.offset(ii + 1) puts %Q("#{capture}" #{soff} .. #{eoff}) end end