Java String Dequote dequote(String str)

Here you can find the source of dequote(String str)

Description

Remove quotes from a string, only if the input string start with and end with the same quote character.

License

Open Source License

Parameter

Parameter Description
str the string to remove surrounding quotes from

Return

the de-quoted string

Declaration

public static String dequote(String str) 

Method Source Code

//package com.java2s;
//  are made available under the terms of the Eclipse Public License v1.0

public class Main {
    /**/*from w  w  w. java  2  s  .co m*/
     * Remove quotes from a string, only if the input string start with and end with the same quote character.
     *
     * @param str
     *            the string to remove surrounding quotes from
     * @return the de-quoted string
     */
    public static String dequote(String str) {
        char start = str.charAt(0);
        if ((start == '\'') || (start == '\"')) {
            // possibly quoted
            char end = str.charAt(str.length() - 1);
            if (start == end) {
                // dequote
                return str.substring(1, str.length() - 1);
            }
        }
        return str;
    }
}

Related

  1. deQuote(String in)
  2. dequote(String inputString)
  3. deQuote(String quotedString)
  4. deQuote(String s)
  5. dequote(String s)
  6. dequote(String str)
  7. dequote(String str)
  8. dequote(String str, char quote)
  9. dequote(String string)