日期:2014-05-20  浏览次数:20636 次

正则表达式将匹配到的字符高亮输出
假设表达式是"\bend\b",使用Match find匹配成功又怎么高亮输出end,成为"weekend"?
或者表达式 "(go\s*)+" 匹配"Let's go go go ",匹配成功后,
并输出"let's go go go" 呢?

------解决方案--------------------
Match成功后,借助Match.replaceAll(),将<font color="read"></font>添加进去,类似于:

String result = match.replaceAll("<font color='red'>$0</font>");