【发布时间】:2015-02-19 23:04:46
【问题描述】:
我需要预处理一个字符串并从中删除一些单词。我正在寻找的是这样的:-
private static final String[] stopWords = { "is", "on", "of", "with"};
String s1 = "Tiger is Mammal with sharp teeth";
System.out.println("s1 = " + s1); // "Tiger is Mammal with sharp teeth"
s1.remove(stopWords); //remove should remove 'is' and 'with' from s1
System.out.println("s1 = " + s1); // "Tiger Mammal sharp teeth"
我是编程新手,所以请考虑一下。
【问题讨论】:
-
首先有一个文档。所以建议大家看看:docs.oracle.com/javase/7/docs/api/java/lang/String.html
-
当然,先生,我会查看文档。