I have string like file name. I want to output like file\ name. I have tried following.
ruby-1.9.2-p290 :060 > s.gsub(/\s/,"\ ")
=> "file name"
ruby-1.9.2-p290 :074 > s.gsub(" ","\\")
=> "file\\name"
Any help would be great.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You probably want
This is a single backslash character, but its representation needs a double backslash to differentiate it from an actual escape sequence like
\n.