Javascript String allIndexOf(toSearch)

Description

Javascript String allIndexOf(toSearch)

String.prototype.allIndexOf = function(toSearch){
    var indices = [];
    for (var pos = this.indexOf(toSearch); pos !== -1; pos = this.indexOf(toSearch, pos + 1)) {
        indices.push(pos);/*from  ww  w. ja v a2 s .  c  om*/
    }
    return indices;
}



PreviousNext

Related