Nodejs String Trimming Right TrimEnd( aimStr )

Here you can find the source of TrimEnd( aimStr )

Method Source Code

String.prototype.TrimEnd = function( aimStr )
{
    var str = this;
    var re = My.RegExp.InvolvedCharsRegExp;
    var reEnd;/*from w  w w.ja v  a2 s. c o m*/
    if ( aimStr )
    {
        aimStr = aimStr.replace( re, '\\$1' );
        reEnd = new RegExp( '(' + aimStr + ')+$' );
    }
    else reEnd = /\s+$/;
    str = str.replace( reEnd, '' );
    return str;
};

Related

  1. trimRight(character)
    String.prototype.trimRight = function (character) {
      character = character || ' ';
      return this.replace(new RegExp('[' + character + ']+$'), "");
    };
    
  2. trimRight(charlist)
    String.prototype.trimRight = function(charlist) {
        "use strict";
        if (charlist === undefined)
            charlist = "\s";
        return this.replace(new RegExp("[" + charlist + "]+$"), "");
    };
    
  3. trimRighttrimRight()
    if (!String.prototype.trimRight)
    String.prototype.trimRight = function trimRight() {
      return this.replace(/(?:\s|\u00A0)+$/, '');
    };
    
  4. rightTrim()
    String.prototype.rightTrim = function () {
        return this.replace(/\s+$/, "");
    
  5. rightTrim()
    String.prototype.rightTrim=function(){
        return this.replace(/\s+$/,'');
    
  6. TrimEnd(v)
    String.prototype.TrimEnd = function (v)
        if (this.substring(this.length - 1, this.length) == v) {
            return this.substring(0, this.length - 1);
        else {
            return this;
    
  7. RTrim()
    String.prototype.RTrim = function() {
        return this.replace(/\s+$/g, "");
    
  8. Rtrim()
    String.prototype.Rtrim = function(){
      return this.replace(/(\s*$)/g, "");
    };
    
  9. endTrim(char)
    String.prototype.endTrim = function (char) {
        let length = this.length;
        if (length) {
            if (this.charAt(length - 1) === char) {
                return this.substring(0, length - 1);
        return this.toString();
    };
    ...