【发布时间】:2014-07-31 22:12:03
【问题描述】:
这是我的代码:
public void storeWords(String sentence)
{
String[] wordlist = sentence.split("\\s+");
int stringLength = wordlist.length;
for(int j = 0; j < stringLength; j++)
{
wordlist[j].replaceAll("[^a-zA-Z ]", "");
System.out.println(wordlist[j]);
}
}
所以现在的 for 循环只是检查是否每个单词都替换了标点符号。没有。我还简单地检查了“sentence.replaceAll(.....)”,但仍然无法正常工作。关于我哪里出错的任何线索?
"If somebody falls and has no protection, do they get hurt?"
返回
"If"
"somebody"
"falls"
"and"
"has"`
"no"
"protection, "
"do"
"they"
"get"
"hurt?"
【问题讨论】:
-
replaceAll 是做什么的,究竟?
标签: java android string replace