"Austin Ziegler" <halostatue / gmail.com> schrieb im Newsbeitrag news:9e7db91104081713254f2eb39e / mail.gmail.com... > This should do what you want. > > -austin > > str = '<span id="1"> <span>...</span> </span>' > re = /(<(\/?)span>)/i > > str.scan(re) # => [["<span>", ""], ["</span>", "/"], ["</span>", "/"]] > > 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 > While that works, isn't it ridiculous that one has to resort to a class method ("Regexp.last_match")? I mean, there should rather be something like /o/.each( "foo" ) do |md| # md is MatchData end Or even /o/.matcher( "foo" ).each do |md| # md is MatchData end That way Matcher could implement Enumerable. Sounds like a candidate for a RCR. Any comments? robert