Here you can find the source of unquote(String quoted)
Parameter | Description |
---|---|
quoted | a parameter |
public static String unquote(String quoted)
//package com.java2s; public class Main { /**// w w w .j ava 2 s . c o m * remove the surrounding quotation mark and restore 2 successive quotation marks to 1 * * @param quoted * @return */ public static String unquote(String quoted) { String content = quoted; if (quoted.indexOf("'") == 0 && quoted.lastIndexOf("'") == quoted.length() - 1 && quoted.length() > 1) { content = quoted.substring(1, quoted.length() - 1).replaceAll("''", "'"); } else if (quoted.indexOf("\"") == 0 && quoted.lastIndexOf("\"") == quoted.length() - 1 && quoted.length() > 1) { content = quoted.substring(1, quoted.length() - 1).replaceAll("\"\"", "\""); } else if (quoted.indexOf("[") == 0 && quoted.lastIndexOf("]") == quoted.length() - 1 && quoted.length() > 1) { content = quoted.substring(1, quoted.length() - 1); } return content; } }