【发布时间】:2015-01-19 18:07:11
【问题描述】:
我正在尝试在字符串中搜索词组,然后用空格替换该词组。这是我的代码:
public void convertToNotes() {
classNotes = (EditText) findViewById(R.id.class_notes);
className = (EditText) findViewById(R.id.class_name);
verifyTextView = (TextView) findViewById(R.id.textView);
verifyTextView.setSingleLine(false);
conversionText = classNotes.getText().toString();
String[] result = conversionText.split(".");
for (int a = 0; a < result.length; a++) {
result[a] = result[a].replaceAll("forget"+ "about"+ "that", "");
result[a] = result[a].replaceAll("important", " <br><u>IMPORTANT</u>");
}
verifyTextView.setText(Html.fromHtml(Arrays.toString(result)));
}
我也试过了:
result[a] = result[a].replaceAll("forget about that", "");
但是这句话仍然没有被删除。
【问题讨论】:
-
replaceAll阅读相关文档。 -
您的意见是什么?
result[]的内容是什么?