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

Stringunescape(String input)
unescape
StringBuilder builder = new StringBuilder();
int i = 0;
while (i < input.length()) {
    char delimiter = input.charAt(i);
    i++; 
    if (delimiter == '\\' && i < input.length()) {
        char ch = input.charAt(i);
        i++;
...
Stringunescape(String input, char escapeChar)
unescape
final StringBuilder out = new StringBuilder();
boolean escapeNext = false;
for (char c : input.toCharArray()) {
    if (c == escapeChar && !escapeNext) {
        escapeNext = true;
    } else {
        out.append(c);
        escapeNext = false;
...
Stringunescape(String line)
unescape
if (line == null) {
    return null;
StringBuffer sb = new StringBuffer();
for (int i = 0, n = line.length(); i < n; i++) {
    char c = line.charAt(i);
    if (c == '\\') {
        if (i == n - 1) {
...
Stringunescape(String line)
Parse html/xml escape sequences
line = line.replace("&amp;", "&");
line = line.replace("&quot;", "\"");
line = line.replace("&gt;", ">");
line = line.replace("&lt;", "<");
return line;
Stringunescape(String line, int start, int end)
unescape
StringBuffer sb = new StringBuffer();
boolean escape = false;
StringBuffer escBuf = new StringBuffer();
for (int i = start; i < end; i++) {
    char c = line.charAt(i);
    switch (c) {
    case '&':
        escape = true;
...
Stringunescape(String literal, String escapedChars)
Removes all escape sequences in a string and return unescaped string escape character is backslash \, so \\ --> \, \' --> ' additional escaped characters can be allowed in escapedChars.
char c = '?';
int i = 0;
if (null == escapedChars) {
    escapedChars = "\\'";
if (null == literal) {
    return null;
int len = literal.length();
if (len == 1 && literal.charAt(0) == '\\') {
    return null;
if (len > 1 && literal.charAt(len - 2) != '\\' && literal.charAt(len - 1) == '\\') {
    return null;
StringBuilder sb = new StringBuilder(len + 16);
for (i = 0; i < len; i++) {
    c = literal.charAt(i);
    if (c == '\\') {
        char escChar = literal.charAt(i + 1);
        boolean matched = false;
        for (int j = 0; j < escapedChars.length(); j++) {
            if (escChar == escapedChars.charAt(j)) {
                sb.append(escChar);
                ++i;
                matched = true;
                break;
        if (!matched) {
            return null;
    } else {
        sb.append(literal.charAt(i));
return sb.toString();
Stringunescape(String name)
unescape
name = name.replaceAll("'\\['", "[");
name = name.replaceAll("'\\]'", "]");
name = name.replaceAll("\\'\\?\\'", "?");
name = name.replaceAll("\\'\\'", "'");
return name;
Stringunescape(String oldStr)
unescape
StringBuilder newStr = new StringBuilder(oldStr.length());
boolean backSlashPresent = false;
for (int i = 0; i < oldStr.length(); i++) {
    int cp = oldStr.codePointAt(i);
    if (oldStr.codePointAt(i) > Character.MAX_VALUE) {
        i++;
    if (!backSlashPresent) {
...
Stringunescape(String original, char[] spec)
unescape
String n = original;
for (char c : spec) {
    n = n.replace("\\" + c, "" + c);
n = original.replace("\\\\", "\\");
return n;
Stringunescape(String property)
Unescapes the property name
return property.replace('$', '.');