On 2/21/07, Xavier Noria <fxn / hashref.com> wrote: > On Feb 21, 2007, at 1:10 PM, Harold Hausman wrote: > > > On 2/21/07, Eyal Oren <eyal.oren / gmail.com> 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. > Dah! I didn't even see that there were even earlier messages. I apologize. What's worse, is that even after looking at this for 20+ mins, I still don't see a way to cleanly do it. Once that backslash is escaped in that string, you're pretty much hosed. I think gsub is your best option here. Though, I'd love to to surprised. (: Apologies, -Harold