Skip to content

Instantly share code, notes, and snippets.

@detomon
detomon / strspn.js
Created March 28, 2014 10:49
JavaScript implementation of the PHP function `strspn`
String.prototype.strspn = function (chars, start, length) {
var end;
if (start == undefined)
start = 0;
else if (start < 0)
start += this.length;
if (length == undefined)
length = this.length;