Nodejs Utililty Methods String Trimming Right

List of utility methods to do String Trimming Right

Description

The list of methods to do String Trimming Right are organized into topic(s).

Method

rTrim()
String.prototype.rTrim = function()
    return this.replace(/([\\s]*$)/g, "");
rTrim()
String.prototype.rTrim = function(){
  str = this;
  var i;
    for(i=str.length-1;i>=0;i--)
        if(str.charAt(i)!=" "&&str.charAt(i)!=" ")break;
    str=str.substring(0,i+1);
    return str;
...
rTrim()
String.prototype.rTrim = function() {
  return this.replace(/(\s*$)/g, "");
};
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();
};
rTrim(charlist)
String.prototype.rTrim = function(charlist) {
  if (charlist === undefined)
    charlist = "\s";
  return this.replace(new RegExp("[" + charlist + "]+$"), "");
};
rtrim()
String.prototype.rtrim = function() {
    return this.replace(/\s+$/,"");
};
rtrim()
String.prototype.rtrim = function() {
    return this.replace(/\s+$/ig, "");
String.prototype.ltrim = function() {
  return this.replace(/^\s+/ig, "");
rtrim()
String.prototype.rtrim = function() {
  return this.replace(/\s+$/g,"");
rtrim()
String.prototype.rtrim = function() {
  return this.replace(/\s*$/g,'');
rtrim()
String.prototype.rtrim=function()
  return this.replace(/(\s*$)/g,'');