In JavaScript, I wanted to do the right trim for all the special characters at the end of the string. My Piece of code doing the trim for hyphen (-) only..Need for all the speci
This should do the trick.
var x = "abcde#$@asbd#$^@$"; x.slice(0,x.search(/\W*$/));
This will only trim off the special characters at the end of the string. It will leave special characters that are in the body of the string.