string text = "good morning. have class. " + "have visit. have fun!"; string[] words = text.split("[ \n\t\r.,;:!?(){"); this split method provided in text book, meant remove delimiters in sentence white space character not working , throws regex exception disappointment....i wondering here make work? requirement after split method, in `string[] words either english words without delimiters attaching or whitespace character! lot!
you missing closing ] in character class:
string[] words = text.split("[ \n\t\r.,;:!?(){]"); btw can (and better option):
string[] words = text.split("\\w+"); to split on non-word character.
Comments
Post a Comment