Posts

Showing posts with the label escaping

Escape json in javascript

Image
Clash Royale CLAN TAG #URR8PPP Escape json in javascript Need to escape the following json { "xx": 'a', "yy": "bb" } into the following structure in javascript {rnt"xx": 'a',rnt"yy": "bb"rn} I have tried the code suggestion from this link, How to escape a JSON string containing newline characters using JavaScript? var request = { "xx": "aaa", "yy": "bb" } var myJSONString = JSON.stringify(request); var myEscapedJSONString = myJSONString.replace(/\n/g, "\n").replace(/\'/g, "\'").replace(/\"/g, '\"').replace(/\&/g, "\&").replace(/\r/g, "\r").replace(/\t/g, "\t").replace(/\b/g, "\b").replace(/\f/g, "\f"); but not worked, please help. Code has to escape like the following Where is your attempted code? – Mamun ...

How to escape bash parameter expansion (when a “!” followed by letters is a parameter)

Image
Clash Royale CLAN TAG #URR8PPP How to escape bash parameter expansion (when a “!” followed by letters is a parameter) I have a bash script I need to call with a string parameter, which string starts with a exclamation mark "!" (this is mandatory in what I'm doing): myCommand.sh "!HELLO" Because of parameter expansion, bash reports an error: -bash: !HELLO: event not found Is there any way to escape the "!" that produces this? Another way to pass such parameter? Use single quotes: myCommand.sh '!HELLO' – anubhava 43 secs ago myCommand.sh '!HELLO' By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the websit...