小编Noj*_*Noj的帖子

java String, replaceall() 但在原始字符串中保留大小写

你好,我制作了一个程序,可以将字符串突出显示到 webview(android) 中,我坚持用这段代码替换有颜色的字符串

        String[] arr = "LION SAVANA".split(" ");//i split textview string to have words (here we suppose that user entered : "lion savana"


        String finalText = "the lion is a species of mamifer living into the savana"

        for (String ss : arr) {
            if (ss.length() > 2) {
                 ss = ss.replace("*","");
                finalText = finalText.replaceAll("(?i)" + ss, "<b style = \"color:#2575ff\";>" + ss + "</b>");//finally here i replace all lion or savana occurrences by blue ones -> but i not …
Run Code Online (Sandbox Code Playgroud)

java regex replace

2
推荐指数
1
解决办法
1767
查看次数

标签 统计

java ×1

regex ×1

replace ×1