I have a simple code:
public static void main(String[] args) {
String s = "He is a very very good boy, isn't he?"
String[] words = s.split("[\\s\\-\\.\\'\\?\\,\\_\\@\\!]");
System.out.println(words.length);
for(int i = 0; i<words.length; i++) {
System.out.println(words[i]);
}
scan.close();
}
that should output me this:
10
He
is
a
very
very
good
boy
isn
t
he
But instead, it prints me out this:
11
He
is
a
very
very
good
boy
isn
t
he
Can anyone suggest me how to fix this issue? I know that the problem is when my program encounter "," it automatically splits the string and then again followed by " " it splits it again so it creates a empty line in my output, but i have no idea how to fix it so it will split multiple delimiters at the same time.

