Java Utililty Methods String Unescape

List of utility methods to do String Unescape

Description

The list of methods to do String Unescape are organized into topic(s).

Method

StringunEscapeString(String str)
un Escape String
if (str == null)
    return null;
str = str.replaceAll("%20", " ");
str = str.replaceAll("%3C", "<");
str = str.replaceAll("%3E", ">");
str = str.replaceAll("%23", "#");
str = str.replaceAll("%7B", "{");
str = str.replaceAll("%7D", "}");
...
StringunescapeString(String string)
Retira o escape de barras invertidas e de aspas duplas de uma string, nesta ordem.
return unescapeDoubleQuote(unescapeReverseSolidus(string));
StringunescapeString(String string, String escapeChars, char escapeSymbol)
Removes occurrences of an escape character from a string.
if (string == null || string.isEmpty() || (escapeChars != null && escapeChars.isEmpty())) {
    return string;
StringBuilder sb = new StringBuilder(string.length());
for (int i = 0; i < string.length(); i++) {
    char c = string.charAt(i);
    if (c == escapeSymbol && i < string.length() - 1) {
        char c2 = string.charAt(i + 1);
...
StringunescapeString(String t)
unescape String
StringBuilder r = new StringBuilder();
int length = t.length();
int j = 0;
while (j < length) {
    char c = t.charAt(j);
    if (c == '\\') {
        c = t.charAt(++j);
        switch (c) {
...
StringunescapeString(String text)

Effectively un-escapes a string, performs the reverse of #escapeString(String) .

if (!needsUnEscaping(text)) {
    return text;
String unescaped = text.replaceAll("\\\\n", "\n");
unescaped = unescaped.replaceAll("\\\\r", "\r");
unescaped = unescaped.replaceAll("\\\\N", "\n");
unescaped = unescaped.replaceAll("\\\\\\\\", "\\\\");
unescaped = unescaped.replaceAll("\\\\,", ",");
...
StringunescapeString(String text)

Effectively un-escapes a string, performs the reverse of #escapeString(String) .

String unescaped = text.replaceAll("\\\\n", "\n");
unescaped = unescaped.replaceAll("\\\\N", "\n");
unescaped = unescaped.replaceAll("\\\\\\\\", "\\\\");
unescaped = unescaped.replaceAll("\\\\,", ",");
unescaped = unescaped.replaceAll("\\\\;", ";");
unescaped = unescaped.replaceAll("\\\\:", ":");
return unescaped;
StringunescapeString(String text)
unescape String
if (text == null) {
    return null;
if (text.length() >= 2 && text.startsWith("\"") && text.endsWith("\"")) {
    text = text.substring(1, text.length() - 1);
if (text.indexOf('\\') >= 0) {
    StringBuilder r = new StringBuilder();
...
StringunescapeString(String txt)
unescape String
txt = txt.replace("&xd;", "\r");
txt = txt.replace("&xa;", "\n");
return txt;
StringunescapeText(String s)
unescape Text
StringBuffer text = new StringBuffer(s);
boolean more = true;
while (more) {
    int i = text.toString().indexOf("\\\""); 
    if (i != -1) {
        text.replace(i, i + 2, "\"");
    } else {
        more = false;
...
StringunescapeText(String s)
Replaces &-excape sequences required by HTML and XML with the character represented by the escape sequence (& < > " and ').
StringBuffer sb = new StringBuffer();
int oldIndex = 0;
int index = s.indexOf('&');
while (index >= 0) {
    sb.append(s.substring(oldIndex, index));
    if (s.startsWith("&amp;", index)) {
        sb.append('&');
        oldIndex = index + 5;
...