Java Utililty Methods String Unquote

List of utility methods to do String Unquote

Description

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

Method

Stringunquote(String s)
unquote
if (s == null) {
    return null;
if (s.startsWith("'") && s.endsWith("'") || s.startsWith("\"") && s.endsWith("\"")
        || s.startsWith("`") && s.endsWith("`")) {
    s = s.substring(1, s.length() - 1);
return s;
...
Stringunquote(String s)
unquote
return unquote(s, "\"");
Stringunquote(String s)
unquote
while (s.startsWith("\"")) {
    s = s.substring(1);
while (s.endsWith("\"")) {
    s = s.substring(0, s.length() - 1);
return s;
Stringunquote(String s)
unquote
return s.startsWith("\"") ? s.substring(1, s.length() - 1) : s;
Stringunquote(String s)
Removes enclosinf apostrophes from the given string
if (s.contains("'")) {
    return s.substring(s.indexOf("'") + 1, s.lastIndexOf("'"));
} else {
    return s;
Stringunquote(String s)
Removes one pair of leading/trailing quotes ("x" or 'x' or `x` becomes x).
if (s == null) {
    return null;
char startChar = s.charAt(0);
char endChar = s.charAt(s.length() - 1);
if ((startChar == '\'' || startChar == '"' || startChar == '`') && startChar == endChar)
    return s.substring(1, s.length() - 1);
else
...
Stringunquote(String s)
remove double quotes around a string
if (s != null && s.length() > 1) {
    if (s.charAt(0) == '\"' && s.charAt(s.length() - 1) == '\"') {
        s = s.substring(1, s.length() - 1);
return s;
Stringunquote(String s, char c)
Useful for unquoting strings, since StringTokenizer won't do it for us.
int firstq = s.indexOf(c);
int lastq = s.lastIndexOf(c);
if (isQuoted(s, c))
    return s.substring(firstq + 1, lastq);
return null;
Stringunquote(String str)
unquote
if (str == null)
    return null;
return str.replaceFirst("^\\\"(.*)\\\"$", "$1");
Stringunquote(String str)
Removes single or double quotes from a String
if (isBlank(str))
    return str;
if ((str.startsWith("'") && str.endsWith("'")) || (str.startsWith("\"") && str.endsWith("\""))) {
    return str.substring(1, str.length() - 1);
return str;