【发布时间】:2015-05-29 14:23:30
【问题描述】:
所以如果我有这个:'我的消息需要检查'。
我有一个字符串:[1][3][4]。这些是我要删除的消息元素(例如,“my”是元素 1,“that”是元素 3)。
我将如何遍历此消息并删除此其他字符串中的元素?
例子:
String messageToFilter = "my message that needs checking";
String filter = "[1]-[3]-[4]";
for (String curElement : filter.split("-")) {
//If I remove element [0], element [3] is then moved to [2]; so not sure what to do!
}
//So at this stage I need the messageToFilter, but with the elements from filter removed.
//In the example above this would output 'message checking'.
【问题讨论】: