Javascript String ltrim()

Description

Javascript String ltrim()


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

Javascript String ltrim()

var s1 = new String('  A  B  ');
//s1.ltrim = function(){
String.prototype.ltrim = function(){
  var regexp = /^\s*/;
  var result = this.replace(regexp, '');
  return result;/* ww w .ja  va 2 s  .  c  o m*/
};
console.log('||'+s1.ltrim()+'||');

Javascript String ltrim()

String.prototype.ltrim = function ()  
{  /*ww w . j  a  va 2  s  .  c om*/
    return this.replace(/(^\s*)/g, "");  
}

Javascript String ltrim()

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

Javascript String ltrim()

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

Javascript String ltrim()

String.prototype.ltrim = function(){
 return this.replace(/^\s+/g/"");
}

Javascript String ltrim()

String.prototype.ltrim=function()
{
  return this.replace(/(^\s*)/g,'');
}

Javascript String ltrim()

String.prototype.ltrim = function() {
    return this.replace(/^\s+/, '');
};

Javascript String ltrim()

/**// www. j av a2 s.  c o m
@Name: String.prototype.ltrim
@Author: Paul Visco
@Version: 1.0 11/19/07
@Description: Trims all white space off the right side of a string
@Return: String The original text with whitespace removed from the right
@Example:
var myString = 'hello              ';

var newString = myString.rtrim();
//newString = 'hello';
*/
String.prototype.ltrim = function(){
 return this.replace(/\s+$/, "");
};

Javascript String lTrim()

String.prototype.lTrim = function(){
 str = this;/*from  w w  w . ja  va 2s  .co  m*/
  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;
}

Javascript String ltrim()

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



PreviousNext

Related