I'm trying to split a string into an array of words, however I want to keep the spaces after each word. Here's what I'm trying:
var re = /[a-z]+[$\s+]/gi;
var test = "test one two three four ";
var results = test.match(re);
The results I expect are:
[0]: "test "
[1]: "one "
[2]: "two "
[3]: "three "
[4]: "four "
However, it only matches up to one space after each word:
[0]: "test "
[1]: "one "
[2]: "two "
[3]: "three "
[4]: "four "
What am I doing wrong?