1function getIndicesOf(searchStr, str, caseSensitive) {
2 var searchStrLen = searchStr.length;
3 if (searchStrLen == 0) {
4 return [];
5 }
6 var startIndex = 0, index, indices = [];
7 if (!caseSensitive) {
8 str = str.toLowerCase();
9 searchStr = searchStr.toLowerCase();
10 }
11 while ((index = str.indexOf(searchStr, startIndex)) > -1) {
12 indices.push(index);
13 startIndex = index + searchStrLen;
14 }
15 return indices;
16}