Regex to split a string (in Java) so that spaces are preserved?
- by david
I need to split a string (in Java) into individual words ... but I need to preserve spaces.
An example of the text I need to split is something like this:
ABC . . . . DEF . . . . GHI
I need to see "ABC", " . . . .", "DEF", ". . . .", and "GHI".
Obviously splitting on the space character \s isn't going to work, as all the spaces get swallowed up as one space.
Any suggestions?
Thanks