Name: indexesOf() - gets array of all indexOf's
Author: senocular: www.senocular.com
Date: 1899-12-31T00:24:51.900
Documentation:
String INDEXESOF: returns all the indexes of the
string as an array
Arguments:
str: (string) the string you want to get the indexes of within the specified main string
Returns:
A numerical array specifying the positions of the str argument in the specified string
Example:
myString = "one day you will have to tell me about toronto."
trace(myString.indexesOf("t")); // 22,25,37,39,44
1
2
3
4
5
6
7
8
String.prototype.indexesOf = function(str){
var pos = 0, ary = [];
do{
if ((pos = this.indexOf(str, pos)) != -1) ary[ary.length] = pos;
else break;
}while(pos += str.length);
return ary;
}