Here you can find the source of ltrim()
/**/* 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+/, ""); };
String.prototype.ltrim = function() { return this.replace(/^\s*/g,'');
String.prototype.ltrim=function() return this.replace(/(^\s*)/g,'');
String.prototype.ltrim = function() { return this.replace(/(^\s*)/g, "");
String.prototype.ltrim = function() { return this.replace(/^\s+/,'');
String.prototype.ltrim = function(){ return this.replace(/\s+$/, ""); };
String.prototype.ltrim = function() return this.replace( /^\s*/g, '' ) ;
String.prototype.ltrim = function(){ var res = this; while (res.substring(0, 1) == " ") { res = res.substring(1, res.length); return res;
String.prototype.ltrim=function() {return this.replace(/^\s+/,'');}
String.prototype.ltrim = function(ch) { var r = new RegExp("^{0}+".format(ch || "\\s")); return this.replace(r, ""); };