Created
December 31, 2013 19:48
-
-
Save coffeencoke/8201402 to your computer and use it in GitHub Desktop.
Why does this happen?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"'this has quotes'".gsub("'", "\\'") # => "this has quotes'this has quotes" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right, missed that you wanted the backslashes. :) For that, you can use %q:
note that if you're testing this in irb, you'll see double backslashes; stick
puts
in front to verify that you're getting the right output.