I have a javascript variable which hold the value taken from somewhere else(lets say from a API call), taken string is given bellow,
He\'s the reason for this
I assign this string to a variable name \’sample\’. But when I print it, it doesn\’t work since the string has \” \’ \” character. I want to add \” \\ \” before the \” \’ \” character. I tried using this,
var sample = (get the string from a api call).replace(/\'/g,\"\\\\\\\'\");
But it doesn\’t work?
Rating:
The post php – Add ' \\ ' before " ' " of a string variable in javascript appeared first on Javascript ASK.
via Javascript ASK http://javascriptask.phpfogapp.com/php-add-before-of-a-string-variable-in-javascript.html
No comments:
Post a Comment