How can I use the str.split() function to get an array of indexes of the matches instead of the actual matches?
e.g.:
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.
Even better yet, this 2D array output would be ideal:
//[[0, "The"], [4, "quick"], [10, "brown"], [16, "fox"], [20, "jumps"], [26, "over"], ...]
Use this method:
Example:
EDIT (Dec. 17, 2018): Avoid adding methods to native String object.