I'm trying to find a way to split a String in Java without ignoring the spaces. After searching I've found a way to do it in python :
re.split(r"(\s+)", "This is the string I want to split")
would result in:
['This', ' ', 'is', ' ', 'the', ' ', 'string', ' ', 'I', ' ', 'want', ' ', 'to', ' ', 'split']
How can this be done in java?