I have string
var myString = 'Hello word Sentence number';
I need make array like ["Hello ","word ","Sentence ","number "]
with space after words, I did myString.split(/(?= )/);
but I received ["Hello"," word"," Sentence"," number"]
How to make that space was after words?
I get this line during the event "keyup" the space is a sign that the word over and it can be compared. I don't need .trim()
splitfunction. Your example is a little unclear because you add a space to the last element,number, even though there's not a space after it in your original string. You can always just loop through the array and manually add a space to each element..trim()that way you don't have to worry about the spaces at all...