Как я могу использовать функцию str.split () , чтобы получить массив индексов совпадений вместо фактических совпадений?
например:.
var str = "The quick brown fox jumps over the lazy dog."
console.log(str.split(' '));
//["The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog."]
//I want to get this output instead for the index positions of the matches
//[0, 4, 10, 16, 20, 26, ...]
//01234567890123456789012345678901234567890123456789
//The quick brown fox jumps over the lazy dog.
Еще лучше, этот вывод двумерного массива был бы идеальным:
//[[0, "The"], [4, "quick"], [10, "brown"], [16, "fox"], [20, "jumps"], [26, "over"], ...]