Forum: Ruby on Rails crazy string issues

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Phil S. (Guest)
on 2009-05-06 14:11
(Received via mailing list)
I can't believe I am having to stoop to asking such a stupid
question!

I want a string that I am sending out to launch a process on windows.
The string has to look like this:

myapp --actx="\\.\DISPLAY3"

I cannot figure out how to get this into a string variable in ruby!

> display = "\\.\DISPLAY3"
=> "\\.DISPLAY3"
>> display.inspect
=> "\"\\\\.DISPLAY3\""

>> display = "\\.\\DISPLAY3"
=> "\\.\\DISPLAY3"
>> display.inspect
=> "\"\\\\.\\\\DISPLAY3\""

How can I get a single slash into a string?
Tony Byrne (Guest)
on 2009-05-06 15:31
(Received via mailing list)
Hi Phil,

On 6 May 2009, at 11:10, phil wrote:

> I cannot figure out how to get this into a string variable in ruby!

display = "\\\\.\\DISPLAY3"

puts display

--> \\.\DISPLAY3

I think the reason you were having problems is that irb shows the
string complete with
escaping characters.  You need to output the string to see what it
actually contains.

Regards,

Tony.
arpit (Guest)
on 2009-05-06 15:39
(Received via mailing list)
"inspect" shows the string with escaped characters..
Phil S. (Guest)
on 2009-05-06 16:05
(Received via mailing list)
Thanks guys!
This topic is locked and can not be replied to.