From: Xavier Noria Date: 2007-02-21T21:28:40+09:00 Subject: Re: interpolation of escaped characters in strings On Feb 21, 2007, at 1:10 PM, Harold Hausman wrote: > On 2/21/07, Eyal Oren wrote: >> E.g. a = 'test\nbreak'. Then "puts a.inspect" doesn't actually >> print a >> line break, it prints the characters '\n'. I would like to transform >> "a" into a string that really includes a linebreak instead of the >> characters '\n'. >> > > It looks like you're running into the fact that when you create a > string literal with a single quote (') it's treated differently than > when you construct the literal with double quotes... Problem is he reads the string 'foo\nbar' from an external source, that is, the string has a literal slash and a literal n within. He wants a nice way to convert that and any other escape sequence into an actual escape sequence. -- fxn