Here you can find the source of unescape(String escaped)
Parameter | Description |
---|---|
escaped | The string to unescape |
public static String unescape(String escaped)
//package com.java2s; public class Main { /**/* w w w. j a va 2 s .co m*/ * Unescape all escape sequences in string (strip one level of backslashes). * An escape sequence always consists of two characters on the form "\ <anychar>". * @param escaped The string to unescape * @return A string with one level of escaping backslashes stripped. */ public static String unescape(String escaped) { char[] source = escaped.toCharArray(); char[] dest = new char[source.length]; int j = 0; for (int i = 0; i < source.length; i++) { if ((source[i] != '\\') || (i > 0 && source[i - 1] == '\\')) { dest[j++] = source[i]; } } return new String(dest, 0, j); } }