Issue
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
Solution
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
Answered By - Rob W Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.