Nodejs String Trimming Right rtrim()

Here you can find the source of rtrim()

Method Source Code

String.prototype.rtrim = function(){
    var res = this;
    while (res.substring(res.length - 1, res.length) == " ") {
        res = res.substring(0, res.length - 1);
    }//from  w w  w  . jav a  2 s . c o m
    return res;
}

Related

  1. rtrim()
    String.prototype.rtrim = function() {
      return this.replace(/\s*$/g,'');
    
  2. rtrim()
    String.prototype.rtrim=function()
      return this.replace(/(\s*$)/g,'');
    
  3. rtrim()
    String.prototype.rtrim = function() {
      return this.replace(/(\s*$)/g, "");
    
  4. rtrim()
    String.prototype.rtrim = function() {
      return this.replace(/\s+$/,'');
    
  5. rtrim()
    String.prototype.rtrim = function()
      return this.replace( /\s*$/g, '' ) ;
    
  6. rtrim()
    String.prototype.rtrim=function()
      {return this.replace(/\s+$/,'');}
    
  7. rtrim(ch)
    String.prototype.rtrim = function(ch) {
        var r = new RegExp("{0}+$".format(ch || "\\s"))
        return this.replace(r, "");
    };
    
  8. rtrim(charlist)
    String.prototype.rtrim = function (charlist) {
      charlist = !charlist ? ' \\s\u00A0' : (charlist + '').replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '$1');
      var re = new RegExp('^[' + charlist + ']+', 'g');
      return this.replace(re, '');
    };
    
  9. trimEnd()
    String.prototype.trimEnd = function() {
      for (var i=this.length-1; this.charAt(i) ==' '; i--) {
        this.substring(0, i);
      return this;
    };