how do i remove backslash at the end of a string?

'\\' means \, you must replace with 4 \\\\, that’s two escaped \

//Use 4 backslashes for \\
//Also remove the $ because escaped characters can be anywhere
var newString = orginalString.replace(/\\/, '\\\\');

Also, I suggest you validate for quotes.

var newString = orginalString.replace(/'/, "\\'");

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top