javascript:
function rtrim ( str, charlist ) {
// Strip whitespace (or other characters) from the end of a string
//
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: Erkekjetter
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1');
var re = new RegExp('[' + charlist + ']+$', 'g');
return str.replace(re, '');
}
//Примеры:
alert ( '"' + rtrim(' Kevin van Zonneveld ') + '"');