From: Andi Schacke Date: 2006-12-12T07:50:59+09:00 Subject: Re: Is there something like Regexp#match_all Robert Klemme wrote: > On 11.12.2006 22:26, Andi Schacke wrote: >> is there a possibility to return all the matches of a regexp? or in >> other words is there a way to apply a block to all matches at once? >> Something like String#gsub but where I can specifiy what to do with the >> matches... > > What exactly do you want to do with matches? > > robert I'd like to build a small web-tool for myself to highlight all the matches of a regexp against a specified string (e.g. the matches should be in a different color). But I think I found a solution: source_string.gsub(regexp) {|match| "#{match}"} -- Posted via http://www.ruby-forum.com/.