String startRegex = "(<|<f|<fo|<fon|<font|<font |<font c|<font co|<font col|<font colo|<font color|<font color=|<font color='|<font color='r|<font color='re|<font color='red|<font color='red'|<font color='red'>|<font color='red'>)$";
Pattern pat = Pattern.compile(startRegex);
Matcher matcher = pat.matcher(content);
while (matcher.find()) {
content = content.replaceAll(startRegex,"");
}
String endRegex = "(</f|</fo|</fon|</font)$";
Pattern pat1 = Pattern.compile(endRegex);
Matcher matcher1 = pat1.matcher(content);
while (matcher1.find()) {
content = content.replaceAll(endRegex,"</font>");
}
String regex = "(<font color='red'>.*)$"; Pattern pat2 = Pattern.compile(regex); Matcher matcher2 = pat2.matcher(content); while (matcher2.find()) { content = content + "</font>"; }