Nodejs String Trim Left lTrim()

Here you can find the source of lTrim()

Method Source Code

String.prototype.lTrim = function () {
   var $whitespace = new String(" \t\n\r");
   if ($whitespace.indexOf(this.charAt(0)) != -1) {
      var $i = this.length;
      var $j = 0;
      while ($j < $i && $whitespace.indexOf(this.charAt($j)) != -1) {
         $j++;/* w w w . j a  v  a2  s  .  co m*/
      }
      return this.substring($j, $i);
   }
   return new String(this);
};

Related

  1. trimLeft(character)
    String.prototype.trimLeft = function (character) {
      character = character || ' ';
      return this.replace(new RegExp('^[' + character + ']+'), "");
    };
    
  2. trimLeft(charlist = '\s')
    String.prototype.trimLeft = function(charlist = '\s') {
        return this.replace(new RegExp('^[' + charlist + ']+'), '');
    };
    
  3. lTrim()
    String.prototype.lTrim = function()
        return this.replace(/(^[\\s]*)/g, "");
    
  4. lTrim()
    String.prototype.lTrim = function(){
      str = this;
       var i;
        for(i=0;i<str.length;i++)
            if(str.charAt(i)!=" "&&str.charAt(i)!=" ")break;
        str=str.substring(i,str.length);
        return str;
    ...
    
  5. lTrim()
    String.prototype.lTrim = function() {
      return this.replace(/(^\s*)/g, "");
    };
    
  6. lTrim(charlist)
    String.prototype.lTrim = function(charlist) {
      if (charlist === undefined)
        charlist = "\s";
      return this.replace(new RegExp("^[" + charlist + "]+"), "");
    };
    
  7. leftTrim()
    String.prototype.leftTrim = function () {
        return this.replace(/^\s+/, "");
    
  8. leftTrim()
    String.prototype.leftTrim = function() { 
       return this.replace(/(^\s*)/g, ""); 
    
  9. leftTrim()
    String.prototype.leftTrim =function(){
        return this.replace(/^\s+/,'');