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(final String in)
dequote
if ((in != null) && !in.isEmpty() && isQuoted(in)) {
    return in.substring(1, in.length() - 1);
return in;
StringdeQuote(String in)
Removes quotes from a string
int len = in.length();
if (in.charAt(0) == '\"' && in.charAt(len - 1) == '\"') {
    if (len > 2) {
        return in.substring(1, len - 1);
    } else {
        return "";
return in;
Stringdequote(String inputString)

This method takes a string and, if the string starts and ends with either " or ', returns the contained string.

Returns the original input string if the inputString's first and last characters were not matching single or double quote characters.

int last = inputString.length() - 1;
if ((inputString.charAt(0) == '"' && inputString.charAt(last) == '"')
        || (inputString.charAt(0) == '\'' && inputString.charAt(last) == '\'')) {
    return inputString.substring(1, last);
return inputString;
StringdeQuote(String quotedString)
de Quote
if (quotedString.startsWith("'") && quotedString.endsWith("'")) {
    return (quotedString.substring(1, quotedString.length() - 1));
return (quotedString);
Stringdequote(String s)
dequote
return dequote(s, new char[] { '"', '\'' });
StringdeQuote(String s)
Removes single or double quotes surrounding a string
if (!isNullOrEmpty(s)) {
    char first = s.charAt(0);
    if (first == '\'' || first == '"') {
        int last = s.lastIndexOf(first);
        if (last > 0) {
            return s.substring(1, last);
return s;
Stringdequote(String str)
Remove quotes from a string, only if the input string start with and end with the same quote character.
char start = str.charAt(0);
if ((start == '\'') || (start == '\"')) {
    char end = str.charAt(str.length() - 1);
    if (start == end) {
        return str.substring(1, str.length() - 1);
return str;
...
Stringdequote(String str)
Simply removes double-quotes from the beginning and end of given string
if (str.startsWith("\""))
    str = str.substring(1);
if (str.endsWith("\""))
    str = str.substring(0, str.length() - 1);
return str;
Stringdequote(String str)
Remove leading and tailing unescaped quotes; remove escaping from escaped internal quotes.
str = str.replace("\\\"", "\"");
if (str.startsWith("\"")) {
    str = str.substring(1);
if (str.endsWith("\"")) {
    str = str.substring(0, str.length() - 1);
return str;
...
Stringdequote(String str, char quote)
Undoubles the quotes inside the string
Example:
 hello""world becomes hello"world 
if (str == null) {
    return null;
return dequote(str, 0, str.length(), quote);