From: Brian Candler Date: 2010-12-30T15:01:02+09:00 Subject: Re: how can i include a double quote in a string Rick Tan wrote in post #971378: > i need to a include a double quote in a string without it being escaped. > For example > > astring="first few characters" > bstring="last characters" > > When i tried > newstring = astring + '"' + bstring + '"' > > newstring ended up as 'first few characters\"last characters\"' $ irb --simple-prompt >> a = "foo" + '"' + "bar" => "foo\"bar" >> puts a foo"bar << NOTE => nil >> puts a.size 7 << NOTE => nil So the string is 7 characters: f o o " b a r irb uses #inspect to display the value of each expression you type. String#inspect escapes double-quotes, so that the value is a valid string literal (i.e. could be pasted back in to Ruby) -- Posted via http://www.ruby-forum.com/.