hi ,
i am trying to replace the '\' with '\\' in jquery.. but its throwing errors
ex: i have a user id test\sample then need to replace with test\\sample since while comparing '\' showing as special character
kindly help me on this
hi ,
i am trying to replace the '\' with '\\' in jquery.. but its throwing errors
ex: i have a user id test\sample then need to replace with test\\sample since while comparing '\' showing as special character
kindly help me on this
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mudzakkir TohaPosted Jun 20, 2023, 1:40 AM
I try this code and it is working
documentation here:
https://www.w3schools.com/jsref/jsref_replace.asp
Murali PPosted Jun 20, 2023, 10:42 AM
thanks to each and everyone for spending time and providing me solution.
this site is increasing confidence..
Vishal JoshiPosted Jun 20, 2023, 5:21 AM
Hello Murali,
Please try the below code to get the expected result.
Thanks
Deepak RawatPosted Jun 20, 2023, 5:09 AM
To replace a single backslash
\with a double backslash\\in a string using jQuery, you can use thereplace()method. Here's an example:Vishal YelvePosted Jun 20, 2023, 4:50 AM
Try this
var myStr = 'test\sample';
var newStr = myStr.replace(/\/g, "\\");
console.log(newStr)
Rajkiran SwainPosted Jun 20, 2023, 4:05 AM