我怎样才能将一个句子分成"He and his brother, are playing football."
几个部分"He"
,如"He and"
,、、、、、、、、、"and his"
和。是否可以通过使用Java来做到这一点?"his brother"
"brother, "
", are"
"brother playing"
"playing football"
"football."
"."
String[] words = "He and his brother , are playing football .".split("\\s+");
System.out.println(words[0]);
for (int i = 0, l = words.length; i + 1 < l; i++){
System.out.println(words[i] + " " + words[i + 1]);
}
String s = words[words.length-1];
System.out.println(s.charAt(s.length() - 1));
这是我做的代码问题是“,”里面的句子必须与单词 like "brother,"
must put 分开,因为这"brother ,"
只会起作用。有什么解决办法吗?