Java String Unescape unescapeString(String s, char enclosed)

Here you can find the source of unescapeString(String s, char enclosed)

Description

unescape String

License

Open Source License

Declaration

public static String unescapeString(String s, char enclosed) 

Method Source Code

//package com.java2s;
/*/*from w w w  .j  a v a 2  s  .  c  om*/
 * QCRI, NADEEF LICENSE
 * NADEEF is an extensible, generalized and easy-to-deploy data cleaning platform built at QCRI.
 * NADEEF means "Clean" in Arabic
 *
 * Copyright (c) 2011-2013, Qatar Foundation for Education, Science and Community Development (on
 * behalf of Qatar Computing Research Institute) having its principle place of business in Doha,
 * Qatar with the registered address P.O box 5825 Doha, Qatar (hereinafter referred to as "QCRI")
 *
 * NADEEF has patent pending nevertheless the following is granted.
 * NADEEF is released under the terms of the MIT License, (http://opensource.org/licenses/MIT).
 */

public class Main {
    public static String unescapeString(String s, char enclosed) {
        // return unchanged when the string is not enclosed.
        if (s.charAt(0) != enclosed)
            return s;

        String reg = "\\\\" + enclosed;
        String replaced = s.replaceAll(reg, Character.toString(enclosed));
        return replaced.substring(1, replaced.length() - 1);
    }
}

Related

  1. unEscapeString(String input)
  2. unescapeString(String oldstr)
  3. unescapeString(String s)
  4. unescapeString(String s)
  5. unescapeString(String s)
  6. unEscapeString(String str)
  7. unescapeString(String str)
  8. unEscapeString(String str)
  9. unEscapeString(String str)