From: James Edward Gray II Date: 2005-05-19T06:18:34+09:00 Subject: Re: (newbie Q) opposite of inspect for strings On May 18, 2005, at 3:45 PM, Basile Starynkevitch [news] wrote: > > Dear All > > I am a novice in Ruby, and I appologize for asking such a basic > questions, but I did not found its answer in the Ruby in a Nutshell > book and after 10 minutes of Googling. > > What is is opposite of inspect for strings, ie the function parsing > strings external representation (as strings)? > > i.e. I do know that "a\tb".inspect gives the 6 character string > "\"a\\tb\"" but what is the method or function that, given the > argument "\"a\\tb\"" produces the "a\tb" string of 3 characters? Is this what you mean? irb(main):001:0> str = "a\tb" => "a\tb" irb(main):002:0> in_file = str.inspect => "\"a\\tb\"" irb(main):003:0> rebuilt = eval in_file => "a\tb" > Also how can I easily parse (ie read) from a file such a string like > the output of inspect? Not sure I understand the question here. Do you know how to open a file and read from it or is that what you want to see? James Edward Gray II