From: Austin Ziegler Date: 2007-02-22T03:36:40+09:00 Subject: Re: Weird behaviour escaping special characters in a string On 2/21/07, Greg Hurrell wrote: > This instance method added to the String class returns a copy of the > receiver with occurrences of \ replaced with \\, and occurrences of ' > replaced with \': > > class String > def to_source_string > gsub(/(\\|')/, '\\\\\1') > end > end class String def to_source_string gsub(/(\\|')/) { "\\#$1" } end end -austin -- Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/ * austin@halostatue.ca * http://www.halostatue.ca/feed/ * austin@zieglers.ca