Javascript String indexOfAfter(searchString, afterIndex)

Description

Javascript String indexOfAfter(searchString, afterIndex)


String.prototype.indexOfAfter = function (searchString, afterIndex) {
    var occurenceAfterIndex = this.substring(afterIndex + searchString.length);
    var diff = this.length - occurenceAfterIndex.length;
    occurenceAfterIndex = occurenceAfterIndex.indexOf(searchString);
    if (occurenceAfterIndex !== -1) {
        occurenceAfterIndex += diff;/*from   w w  w .j  a  v  a 2  s  .c  om*/
    }
    return occurenceAfterIndex;
};



PreviousNext

Related