Nodejs String Trimming Right trimRight(charlist)

Here you can find the source of trimRight(charlist)

Method Source Code

String.prototype.trimRight = function(charlist) {
    "use strict";
    if (charlist === undefined)
        charlist = "\s";

    return this.replace(new RegExp("[" + charlist + "]+$"), "");
};

Related

  1. trimEnd(s)
    String.prototype.trimEnd = function(s) {
        return this.replace(new RegExp(s + "+$", "gm"), "")
    
  2. trimEnd(trimStr)
    String.prototype.trimEnd = function (trimStr) {
        if (!trimStr) {
            return this;
        var temp = this;
        while (true) {
            if (temp.substr(temp.length - trimStr.length, trimStr.length) != trimStr) {
                break;
            temp = temp.substr(0, temp.length - trimStr.length);
        return temp;
    
  3. trimRight()
    String.prototype.trimRight = String.prototype.trimRight || function() {
      return this.replace(/\s+$/,'');
    };
    
  4. trimRight()
    String.prototype.trimRight = String.prototype.trimRight || function () {
        return this.replace(/\s+$/g, "");
    };
    String.prototype.trimLeft = String.prototype.trimLeft || function () {
        return this.replace(/^\s+/g, "");
    };
    String.prototype.endsWith = String.prototype.endsWith || function(suffix) {
        return this.length ? this.lastIndexOf(suffix) === this.length - 1 : false;
    };
    ...
    
  5. trimRight(character)
    String.prototype.trimRight = function (character) {
      character = character || ' ';
      return this.replace(new RegExp('[' + character + ']+$'), "");
    };
    
  6. trimRighttrimRight()
    if (!String.prototype.trimRight)
    String.prototype.trimRight = function trimRight() {
      return this.replace(/(?:\s|\u00A0)+$/, '');
    };
    
  7. rightTrim()
    String.prototype.rightTrim = function () {
        return this.replace(/\s+$/, "");
    
  8. rightTrim()
    String.prototype.rightTrim=function(){
        return this.replace(/\s+$/,'');
    
  9. TrimEnd( aimStr )
    String.prototype.TrimEnd = function( aimStr )
        var str = this;
        var re = My.RegExp.InvolvedCharsRegExp;
        var reEnd;
        if ( aimStr )
            aimStr = aimStr.replace( re, '\\$1' );
            reEnd = new RegExp( '(' + aimStr + ')+$' );
    ...