From: Jean Nibee Date: 2009-04-13T12:56:17+09:00 Subject: Regexp and using the matched value returned/found. Hi I'm trying to do a regex search and using what I find a key to a Hash to dig up some formatting info. But what's happening is the literal \\1 or \\0 (or \1 \0) is not being resolved to what's being found. Any help would be awesome. Ex: (Doesn't work) # regex looks like this: @swi_start = /SWI((dm)|(ph)|(ty)|(st))st/ // executed in my code: line.gsub!( swi_start, self.colorize_token( '\\1' ) ) # also not working: line.gsub!( swi_start, self.colorize_token( '\1' ) ) def colorize_token( event ) puts "Event: " << event return "" end Output: Event: \1 Ex: (This worked!!!) line.gsub!( swi_start, "#{@red_start}\\1#{@red_end}") then Output: dm Lastly please notes I've tried using " instead of ' in my method call without any change. -- Posted via http://www.ruby-forum.com/.