Alex Rivera | Logout

Escaping single and double quotes in a string in ruby?

Asked 2011-07-15T10:56:23.547
86

How can I escape single and double quotes in a string?

I want to escape single and double quotes together. I know how to pass them separately but don't know how to pass both of them.

e.g: str = "ruby 'on rails" " = ruby 'on rails"

Edit
Report

1 Answer

7
>> str = "ruby 'on rails\" \" = ruby 'on rails"
=> "ruby 'on rails" " = ruby 'on rails"
answered 2011-07-15T10:59:18.083

Your Answer