Here you can find the source of rtrim()
String.prototype.rtrim = function() { return this.replace(/(\s*$)/g, ""); }
String.prototype.rtrim = function() { return this.replace(/\s+$/,""); };
String.prototype.rtrim = function() { return this.replace(/\s+$/ig, ""); String.prototype.ltrim = function() { return this.replace(/^\s+/ig, "");
String.prototype.rtrim = function() { return this.replace(/\s+$/g,"");
String.prototype.rtrim = function() { return this.replace(/\s*$/g,'');
String.prototype.rtrim=function() return this.replace(/(\s*$)/g,'');
String.prototype.rtrim = function() { return this.replace(/\s+$/,'');
String.prototype.rtrim = function() return this.replace( /\s*$/g, '' ) ;
String.prototype.rtrim = function(){ var res = this; while (res.substring(res.length - 1, res.length) == " ") { res = res.substring(0, res.length - 1); return res;
String.prototype.rtrim=function() {return this.replace(/\s+$/,'');}