Java Utililty Methods String Dequote

List of utility methods to do String Dequote

Description

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

Method

Stringdequote(String string)
Remove all quote characters from a specified String , including single (') and double (") quotes.
if (string == null) {
    return null;
} else {
    string = string.trim();
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < string.length(); i++) {
        char c = string.charAt(i);
        if (c != '\"' && c != '\'' && c != '`') {
...
Stringdequote(String text)
dequote
return text.substring(0, text.length());
Stringdequote(String value)
dequote
if (isDoubleQuoted(value)) {
    value = value.substring(1, value.length() - 1);
    value = value.replaceAll("\"\"", "\"");
if (value.equals(" ")) {
    return "";
return value;
...
Stringdequote(String value)
dequote
if (value.length() < 2)
    return value;
char f = first(value);
char l = last(value);
if ((f == '"' && l == '"') || (f == '\'' && l == '\'')) {
    return value.substring(1, value.length() - 1);
return value;
...
StringdequoteFull(String str, char quote)
Removes the surrounding quote and any double quote inside the string
Example:
 "hello""world" becomes hello"world 
if (str == null) {
    return null;
return dequoteFull(str, 0, str.length(), quote);
StringdequoteIdentifier(String id)
dequote Identifier
if (id.startsWith(SINGLE_QUOTE_STRING) && id.endsWith(SINGLE_QUOTE_STRING)) {
    return id.substring(1, id.length() - 1);
} else {
    return id;
StringdequoteString(String s)
dequoteString
String dequoteStr = s.trim();
if (dequoteStr.startsWith("'") && dequoteStr.endsWith("'")) {
    dequoteStr = dequoteStr.substring(1);
    dequoteStr = dequoteStr.substring(0, dequoteStr.length() - 1);
    return dequoteStr;
return s;
StringdequoteString(String str)
Replace quoted characters by their unquoted version.
if (str.indexOf('\\') == -1)
    return str;
char[] buf = str.toCharArray();
int pos = 0, num_deq = 0;
while (pos < buf.length) {
    if (buf[pos] == '\\' && pos + 1 < buf.length) {
        System.arraycopy(buf, pos + 1, buf, pos, buf.length - pos - 1);
        num_deq++;
...
StringdequoteString(String str)
Removes matched quotes (single or double) from a string.
if (str != null && str.length() > 1 && ((str.charAt(0) == '"' || str.charAt(0) == '\'')
        && str.charAt(str.length() - 1) == str.charAt(0))) {
    return str.substring(1, str.length() - 1);
return str;
StringdequoteString(String strVal)
Replaces all html/xml expressions for newline and carriage return within the given string value with their java counterpart, namely '\n' and '\r'.
String newStr = strReplace(strVal, "&#13;", "\r"); 
return strReplace(newStr, "&#10;", "\n");