Count String Leading Spaces - Node.js String

Node.js examples for String:String Value

Description

Count String Leading Spaces

Demo Code


String.prototype.countLeadingSpaces = function() {
  var a = this.match(/^\s*/);
  if (a != null && a.length > 0 && a[0].isString)
    return a[0].length;
}

//eof/*from   w  ww  . jav a2  s  .c  om*/

Related Tutorials