In javascript, how to I do a right trim?
I have the following:
var s1 = "this is a test~";
var s = s1.rtrim('~')
but was not successful
Use a RegExp. Don't forget to escape special characters.
s1 = s1.replace(/~+$/, ''); //$ marks the end of a string
// ~+$ means: all ~ characters at the end of a string