The .trim() method of jQuery refers to whitespace ..
Description: Remove the whitespace from the beginning and end of a string.
You need
string1.replace(/~+$/,'');
This will remove all trailing ~.
So one~two~~~~~ would also become one~two
The .trim() method of jQuery refers to whitespace ..
Description: Remove the whitespace from the beginning and end of a string.
You need
string1.replace(/~+$/,'');
This will remove all trailing ~.
So one~two~~~~~ would also become one~two