【发布时间】:2016-08-14 02:19:46
【问题描述】:
好的,我已经编写了将段落拆分为句子的代码。这是下面。但是现在我想在“split”这个词处拆分句子。但如何?
import java.util.*;
import java.util.regex.*;
public class sub {
public static void main(String[] args) {
String test ="As World War split II loomed after 1938, with the Japanese invasion split of China and the aggression of Nazi Germany, Roosevelt gave strong diplomatic split and financial support to China and the United Kingdom, while remaining split officially neutral";
String[] sHolder = test.split("[.,?]");
for (int i = 0; i < sHolder.length; i++){
sHolder [i] = sHolder[i].replaceAll("\\[a-z]", "");
}
}
【问题讨论】:
-
不确定是否应该在
,上拆分句子。可以按空格分割成单词。 -
好吧,改变你的正则表达式。如果你想在
"split"上拆分,那有什么问题?