From: 7stud -- Date: 2011-04-07T08:58:55+09:00 Subject: Re: Match a pattern multiple times, returning matches, captures and offset? You can also get the relative offset like this: str = "_foo_ _bar_" str.scan(/_(\w+)_/) do |curr_match| md = Regexp.last_match whole_match = md[0] captures = md.captures captures.each do |capture| p [whole_match, capture, whole_match.index(capture)] end -- Posted via http://www.ruby-forum.com/.