From: Robert Klemme Date: 2006-12-12T19:15:05+09:00 Subject: Re: Is there something like Regexp#match_all On 11.12.2006 23:56, James Edward Gray II wrote: > On Dec 11, 2006, at 4:50 PM, Andi Schacke wrote: >> 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| "> style=\"color:red;\">#{match}"} > > You don't really need the block form for such a simple replacement. > This is the same thing: > > source_string.gsub(regexp, '\&') ... and in fact more efficient IIRC. robert