Java String Unquote unquotedString(String str)

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

Description

unquoted String

License

Open Source License

Declaration

public static String unquotedString(String str) 

Method Source Code

//package com.java2s;
/** // ww  w.j av  a  2s. co  m
    
 Copyright 2013 Intel Corporation, All Rights Reserved.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License. 
 */

public class Main {
    public static String unquotedString(String str) {
        // if(str.startsWith("\""))
        // {
        // str = str.substring(1);
        // }
        // if(str.endsWith("\""))
        // {
        // str = str.substring(0, str.length()-2);
        // }

        return trim(str, "\"");
    }

    public static String trim(String str, String delimiter) {
        if (str.startsWith(delimiter)) {
            str = str.substring(delimiter.length());
        }
        if (str.endsWith(delimiter)) {
            str = str.substring(0, str.length() - delimiter.length());
        }

        return str.trim();
    }
}

Related

  1. unquote(String value)
  2. unquoteAtom(String atom)
  3. unquoteCharacterLiteral(String charLiteralStr)
  4. unquoteCString(String str)
  5. unquotedCharLiteral(char c)
  6. unquoteHtmlContent(String x)
  7. unQuoteIdentifier(String identifier, boolean useAnsiQuotedIdentifiers)
  8. unQuoteIdentifier(String identifier, String quoteChar)
  9. unQuoteIdentifier(String identifier, String quoteChar)