Java tutorial
//package com.java2s; /* * Copyright (C) 2002-2014 FlyMine * * This code may be freely distributed and modified under the * terms of the GNU Lesser General Public Licence. This should * be distributed with the code. See the LICENSE file for more * information or http://www.gnu.org/copyleft/lesser.html. * */ import java.util.HashMap; import java.util.Map; public class Main { private static Map<String, String> replacements = new HashMap<String, String>(); /** * Replace greek character entity names with entity names that work in HTML. * @param value input string * @return string with replacements */ public static String fixEntityNames(String value) { String retVal = value; if (retVal.indexOf('&') != -1) { for (Map.Entry<String, String> entry : replacements.entrySet()) { String orig = entry.getKey(); String replacement = entry.getValue(); retVal = retVal.replaceAll("&" + orig + ";", "&" + replacement + ";"); if (retVal.indexOf('&') == -1) { break; } } } return retVal; } }