I'm looking to separate a string while preserving white space, for example:
var str = "my car is red";
var stringArray [];
stringArray [0] = "my";
stringArray [1] = " ";
stringArray [2] = "car";
stringArray [3] = " ";
stringArray [4] = "is";
stringArray [5] = " ";
stringArray [6] = "red";
What's the best way to achieve this?
Thank you!