How would I split this complex string into an String array?
I have a text file that I have to read and there was this complex string that I have to store into a String array. I have read about regex, but would really like if someone could help me understand how a complex string such as this could be broken into tokens and stored in an array
String sentence = "I said, "Mr. Jones’ golf 'golden' clubs were broken"."
Maybe using
scanner.next()
And then removing each of those punctuation marks, but how would I end up doing that?
The final array i'd like an array that looks like the
> Array words[] = {"I", "said", "Mr", "Jones", "golf", "golden", "clubs", "were", "broken"};
Any help is appreciated, thank you!
Re: How would I split this complex string into an String array?
Use string split with a space as the delimiter to put the items into an array. Then walk the array and remove punctuation from each array elemnt.