From: Mark Hubbart Date: 2004-04-25T04:48:36+09:00 Subject: Re: gsub oddity? On Apr 24, 2004, at 10:10 AM, Michael Neumann wrote: > Hi, > > "\000".gsub("\000") { "\\000" } > # => "\\000" > > "\000".gsub("\000", "\\000") > # => "\00000" > > I expected both to return the same result. > Just tell me it's not a bug and I'm happy :-) Not a bug :) When used in an argument rather than in a block, \0 inserts the matched string. So gsub("\000", "\\000") is really saying "replace any null characters with themselves followed by two zeros". The block form does not interpolate backslashed matches. cheers, --Mark