我有 EditTextsearchKeyword在段落内搜索(段落在 SQLite 数据库中)。
String Contentstr = paragraph.replaceAll(searchKeyword,"<font color=\"red\">" + searchKeyword + "</font>");
txtV.setText(Html.fromHtml(Contentstr));
上面的代码高亮如下:
当我搜索“Hi hi”(searchKeyword=" Hi hi")时,数据库搜索功能返回任意大小写字母(我的意思是“ hI hi”或“ HI HI”或等等),它会高亮显示“ Hi hi”,但会替换所有其他的“ hI HI”、“ hI hi” 、。 . 等进入 searchKeyword=" Hi hi"。
我不想那样换。
当我搜索“ Hi hi”时,它必须突出显示“ Hi hi”和其他“ hI hi”或“ HI HI”而不将其他替换为“ Hi hi”。