Java String Unescape unescape(String val)

Here you can find the source of unescape(String val)

Description

unescape

License

BSD License

Declaration

private static String unescape(String val) 

Method Source Code

//package com.java2s;
/*/*  w  ww.  j  a  v a 2 s. co  m*/
 * Copyright (c) 2002-2017, the original author or authors.
 *
 * This software is distributable under the BSD license. See the terms of the
 * BSD license in the documentation provided with this software.
 *
 * http://www.opensource.org/licenses/bsd-license.php
 */

public class Main {
    private static final char ESCAPE_CHAR = '\\';
    private static final String MARKER = "@__";

    private static String unescape(String val) {
        val = val.replaceAll(MARKER, "@");
        int escape = val.indexOf(ESCAPE_CHAR);
        while (escape >= 0 && escape < val.length() - 1) {
            char c = val.charAt(escape + 1);
            if (c == '{' || c == '}' || c == ESCAPE_CHAR) {
                val = val.substring(0, escape) + val.substring(escape + 1);
            }
            escape = val.indexOf(ESCAPE_CHAR, escape + 1);
        }
        return val;
    }
}

Related

  1. unescape(String text)
  2. unescape(String text)
  3. unescape(String text)
  4. unescape(String text)
  5. unescape(String theValue)
  6. unescape(String val, char quote)
  7. unescape(String value)
  8. unescape(String value)
  9. unescape(String value)