Nodejs String Trim Left ltrim()

Here you can find the source of ltrim()

Method Source Code

/**/* w w w .ja va2s.co  m*/
@Name: String.prototype.ltrim
@Author: Paul Visco
@Version: 1.0 11/19/07
@Description: Trims all white space off the left side of a string
@Return: String The original text with whitespace removed from the left
@Example:
var myString = '           hello';

var newString = myString.ltrim();
//newString = 'hello';

//or
String.prototype.ltrim.call(myString);
*/
String.prototype.ltrim = function(){
   return this.replace(/^\s+/, "");
};

Related

  1. ltrim()
    String.prototype.ltrim = function() {
      return this.replace(/^\s*/g,'');
    
  2. ltrim()
    String.prototype.ltrim=function()
      return this.replace(/(^\s*)/g,'');
    
  3. ltrim()
    String.prototype.ltrim = function() {
      return this.replace(/(^\s*)/g, "");
    
  4. ltrim()
    String.prototype.ltrim = function() {
      return this.replace(/^\s+/,'');
    
  5. ltrim()
    String.prototype.ltrim = function(){
      return this.replace(/\s+$/, "");
    };
    
  6. ltrim()
    String.prototype.ltrim = function()
      return this.replace( /^\s*/g, '' ) ;
    
  7. ltrim()
    String.prototype.ltrim = function(){
        var res = this;
        while (res.substring(0, 1) == " ") {
            res = res.substring(1, res.length);
        return res;
    
  8. ltrim()
    String.prototype.ltrim=function()
      {return this.replace(/^\s+/,'');}
    
  9. ltrim(ch)
    String.prototype.ltrim = function(ch) {
        var r = new RegExp("^{0}+".format(ch || "\\s"));
        return this.replace(r, "");
    };