From: Ronald Fischer Date: 2007-09-10T23:31:25+09:00 Subject: Re: gsub! and quoting question > > Hmmm... I would understand your argument if I had a digit following > > a backslash (which would mean a backreference to the n-th group in > > the pattern), but here we have \', and this is not a back reference, > > isn't it? At least the discussion of String#gsub at > > http://www.ruby-doc.org/core/ > > mentions only \1,\2,... etc. as back references. > > No. You want the backslash to be interpreted literally by the regexp > engine, i.e. you want to prevent the regexp engine from identifying > the backslash as a meta character. OK > This is independent from the > character *after* the backslash. Ah, that's the point I was missing. Now things are clear! > Btw, not only digits are meaningful in replacement patterns, but > single quote is as well (I believe it's the postmatch): I already suspected this too (knowing this concept from Perl), but didn't find anything in the Ruby online docs where this would be discussed. But this explains why my string was replaced by the empty string... Ronald -- Ronald Fischer Phone: +49-89-452133-162