Java String Dequote deQuote(String in)

Here you can find the source of deQuote(String in)

Description

Removes quotes from a string

License

Open Source License

Parameter

Parameter Description
in a quoted string

Return

the string without enclosing quotes; if in is not quoted, the original string is returned.

Declaration

public static String deQuote(String in) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from w w w  . ja  v a2 s  .  co m
     * Removes quotes from a string
     * 
     * @param in a quoted string
     * @return the string without enclosing quotes; if <code>in</code> is not
     *         quoted, the original string is returned.
     */
    public static String deQuote(String in) {
        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;
    }
}

Related

  1. dequote(final String in)
  2. dequote(String inputString)
  3. deQuote(String quotedString)
  4. dequote(String s)
  5. deQuote(String s)