Skip to content

Instantly share code, notes, and snippets.

@flores
Created October 10, 2012 21:03
Show Gist options
  • Save flores/3868385 to your computer and use it in GitHub Desktop.
Save flores/3868385 to your computer and use it in GitHub Desktop.
tonina:~# # lameness above (js)
tonina:~# node nodetest
\"I\"+\"want\"+\"easy escaping\"
tonina:~# #Ruby
tonina:~# irb
irb(main):001:0> %Q{"I"+"want"+"easy escaping"}
=> "\"I\"+\"want\"+\"easy escaping\""
function Q(string){
replaced=string.replace(/"/g,'\\"');
return replaced;
}
console.log(Q('"I"+"want"+"easy escaping"'));
function Q(string){
replaced=string.replace(/"/g,'\\"');
return replaced;
}
console.log(Q('"I"+"want"+"easy escaping"'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment