Java String Unquote unquote(String string, char quote)

Here you can find the source of unquote(String string, char quote)

Description

Remove any surrounding quotes from a string

License

Open Source License

Parameter

Parameter Description
string a parameter
quote quoting character

Return

udpated string

Declaration

public static String unquote(String string, char quote) 

Method Source Code

//package com.java2s;
/*/*from   ww  w  .j av  a  2  s  .  co  m*/
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of the License "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
 *
 * Description: 
 *
 */

public class Main {
    /**
     * Remove any surrounding quotes from a string
     * @param string
     * @param quote quoting character
     * @return udpated string
     */
    public static String unquote(String string, char quote) {
        if (string.length() >= 2 && string.charAt(0) == quote
                && string.charAt(string.length() - 1) == quote)
            return string.substring(1, string.length() - 1);
        else
            return string;
    }
}

Related

  1. unquote(String string)
  2. unquote(String string)
  3. unquote(String string)
  4. unquote(String string)
  5. unquote(String string)
  6. unquote(String text)
  7. unquote(String text)
  8. unquote(String text)
  9. unquote(String toUnquote, char quoteChar)