-
October 18th, 2018, 09:08 AM
#1
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!
-
October 18th, 2018, 11:24 AM
#2
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|