String.replaceAll的问题.
String keywordPattern = "(?i) "+ keyword;
contentStr = contentStr.replaceAll(keywordPattern, " <font color= '#FF0000 '> "+ keyword + " </font> ");
在英语中有大小写,比如: "java ", "Java ", "JAVA ", "jAVA ",我用(?i)来匹配的话,后面的加量该怎么写?即如何拿到匹配的引用?
lucene的highlighten不行,因为分词的那个组件和highlight有兼容性问题;所以不考虑你推荐的highlighten了.
谢谢!
------解决方案--------------------String keywordPattern = "(?i)( "+ keyword + ") ";
contentStr = contentStr.replaceAll(keywordPattern, " <font color= '#FF0000 '> $1 </font> ");