For example this string: "This is my example "
I want to split it into: ["This", " ", "is", " ", "my", " ", "example", " "]
Right now I am using the look ahead and look back regex to preserve the spaces:
string.split("(?<=\\s+)|(?=\\s+)"))
but it is splitting on every single space:
["This", " ", " ", " ", " ", " ", " ", "is", " ", "my", ...]
How do you write up a regex that splits on and preserve the chunk of spaces?