Nodejs String Trimming Right rtrim()

Here you can find the source of rtrim()

Method Source Code

// trim whitespaces right
String.prototype.rtrim = function() {
  return this.replace(/\s*$/g,'');
}

Related

  1. rTrim()
    String.prototype.rTrim = function () {
      var $whitespace = new String(" \t\n\r");
      if ($whitespace.indexOf(this.charAt(this.length - 1)) != -1) {
        var $i = this.length - 1;
        while ($i >= 0 && $whitespace.indexOf(this.charAt($i)) != -1) {
          $i--;
        return this.substring(0, $i + 1);
      return new String(this);
    };
    String.prototype.trim = function () {
      return this.lTrim().rTrim();
    };
    
  2. rTrim(charlist)
    String.prototype.rTrim = function(charlist) {
      if (charlist === undefined)
        charlist = "\s";
      return this.replace(new RegExp("[" + charlist + "]+$"), "");
    };
    
  3. rtrim()
    String.prototype.rtrim = function() {
        return this.replace(/\s+$/,"");
    };
    
  4. rtrim()
    String.prototype.rtrim = function() {
        return this.replace(/\s+$/ig, "");
    String.prototype.ltrim = function() {
      return this.replace(/^\s+/ig, "");
    
  5. rtrim()
    String.prototype.rtrim = function() {
      return this.replace(/\s+$/g,"");
    
  6. rtrim()
    String.prototype.rtrim=function()
      return this.replace(/(\s*$)/g,'');
    
  7. rtrim()
    String.prototype.rtrim = function() {
      return this.replace(/(\s*$)/g, "");
    
  8. rtrim()
    String.prototype.rtrim = function() {
      return this.replace(/\s+$/,'');
    
  9. rtrim()
    String.prototype.rtrim = function()
      return this.replace( /\s*$/g, '' ) ;