Java String Unescape unescape(String text)

Here you can find the source of unescape(String text)

Description

Unescapes the provided text with XML entities, see (http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entities_in_XML)

License

Open Source License

Parameter

Parameter Description
text a parameter

Declaration

private static String unescape(String text) 

Method Source Code

//package com.java2s;
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved
 * (c) 2001 - 2013 OpenPlans/*from   w w w  .jav  a2 s .c  o  m*/
 * This code is licensed under the GPL 2.0 license, available at the root
 * application directory.
 */

public class Main {
    /**
     * Unescapes the provided text with XML entities, 
     * see (http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entities_in_XML)
     * @param text
     *
     */
    private static String unescape(String text) {
        String s = text;
        if (s != null && s.matches(".*&(.*);.*")) {
            s = s.replaceAll(""", "\"");
            s = s.replaceAll("&", "&");
            s = s.replaceAll("'", "'");
            s = s.replaceAll("&lt;", "<");
            s = s.replaceAll("&gt;", ">");
        }
        return s;
    }
}

Related

  1. unescape(String string)
  2. unescape(String string)
  3. unescape(String string)
  4. unescape(String string, int escape)
  5. unescape(String text)
  6. unescape(String text)
  7. unescape(String text)
  8. unescape(String text)
  9. unescape(String theValue)