Here you can find the source of unescapeString(String s)
public static String unescapeString(String s)
//package com.java2s; /**/* w ww.j a v a 2 s . co m*/ * Copyright (c) 2011, 2014 Eurotech and/or its affiliates * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Eurotech */ public class Main { public static String unescapeString(String s) { String value = s; // remove all space at the beginning of the string which are not escaped value = value.replaceAll("^((?<!\\\\) )*", ""); // remove all space at the end of the string which are not escaped value = value.replaceAll("((?<!\\\\) )*$", ""); // replace all escaped spaces with just space // The pattern covers for any even number of backslashes before the space char value = value.replaceAll("\\\\(\\\\\\\\)* ", " "); // replace all escaped comma with just comma // The pattern covers for any even number of backslashes before the comma char value = value.replaceAll("\\\\(\\\\\\\\)*,", ","); return value; } }