I have been using myString.split("\\s+"); to get the each word. But now I want to split the commas and full stops aswell. For Example:
Mama always said life was like a box of chocolates, you never know what you’re gonna get.
to:
{Mama, always, said, life, was, like, a, box, of, chocolates ,,, You, never, know, what, you're, gonna, get,.,}
How would one go about doing this?
If commas and periods are always followed by whitespace or end-of-string, then you can write:
If they’re not and you want e.g.
a,bto be split into three strings, then: