How can I split a string without removing the delimiters?
Let's say I have a string:
var string = "abcdeabcde";
When I do
var newstring = string.split("d")
, I get something like this:
["abc","eabc","e"]
But I want to get this:
["abc","d","eabc","d","e"]
When I tried to do my "split2" function, I got all entangled in splice() and indexes and "this" vs "that" and ... aargh! Help! :D
Try:
"abcdeabcde".split(/(d)/);