mirror of
https://github.com/leanote/leanote-android.git
synced 2025-10-15 14:51:04 +00:00
@@ -26,6 +26,7 @@ import org.houxg.leamonax.model.Notebook;
|
|||||||
import org.houxg.leamonax.service.NoteFileService;
|
import org.houxg.leamonax.service.NoteFileService;
|
||||||
import org.houxg.leamonax.utils.FileUtils;
|
import org.houxg.leamonax.utils.FileUtils;
|
||||||
import org.houxg.leamonax.utils.HtmlUtils;
|
import org.houxg.leamonax.utils.HtmlUtils;
|
||||||
|
import org.houxg.leamonax.utils.StringUtils;
|
||||||
import org.houxg.leamonax.utils.TimeUtils;
|
import org.houxg.leamonax.utils.TimeUtils;
|
||||||
import org.houxg.leamonax.widget.NoteList;
|
import org.houxg.leamonax.widget.NoteList;
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ public class NoteAdapter extends RecyclerView.Adapter<NoteAdapter.NoteHolder> {
|
|||||||
if (TextUtils.isEmpty(titleKeyWord)) {
|
if (TextUtils.isEmpty(titleKeyWord)) {
|
||||||
mTitleHighlight = null;
|
mTitleHighlight = null;
|
||||||
} else {
|
} else {
|
||||||
mTitleHighlight = Pattern.compile(titleKeyWord, Pattern.CASE_INSENSITIVE);
|
mTitleHighlight = Pattern.compile(StringUtils.escapeRegex(titleKeyWord), Pattern.CASE_INSENSITIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -54,4 +54,21 @@ public class StringUtils {
|
|||||||
public interface Replacer {
|
public interface Replacer {
|
||||||
String replaceWith(String original, Object... extraData);
|
String replaceWith(String original, Object... extraData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//转义正则表达式中的几个特殊符号
|
||||||
|
public static String escapeRegex(String str) {
|
||||||
|
int length = str.length();
|
||||||
|
StringBuilder sbf = new StringBuilder();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
char c = str.charAt(i);
|
||||||
|
if (c == '*') {
|
||||||
|
sbf.append('\\').append(c);
|
||||||
|
} else if (c == '+') {
|
||||||
|
sbf.append('\\').append(c);
|
||||||
|
} else if (c == '?') {
|
||||||
|
sbf.append('\\').append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sbf.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user