Java String Unescape unescapeString(String text)

Here you can find the source of unescapeString(String text)

Description

Effectively un-escapes a string, performs the reverse of #escapeString(String) .

License

Open Source License

Parameter

Parameter Description
text a parameter

Declaration

public static String unescapeString(String text) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  w  ww  . ja v a 2  s  . co  m*/
     * <p>Effectively un-escapes a string, performs the reverse of {@link #escapeString(String)}.</p>
     *
     * @param text
     * @return {@link String}
     */
    public static String unescapeString(String text) {
        String unescaped = text.replaceAll("\\\\n", "\n");
        unescaped = unescaped.replaceAll("\\\\N", "\n");
        unescaped = unescaped.replaceAll("\\\\\\\\", "\\\\");
        unescaped = unescaped.replaceAll("\\\\,", ",");
        unescaped = unescaped.replaceAll("\\\\;", ";");
        unescaped = unescaped.replaceAll("\\\\:", ":");
        return unescaped;
    }
}

Related

  1. unEscapeString(String str)
  2. unescapeString(String string)
  3. unescapeString(String string, String escapeChars, char escapeSymbol)
  4. unescapeString(String t)
  5. unescapeString(String text)
  6. unescapeString(String text)
  7. unescapeString(String txt)
  8. unescapeText(String s)
  9. unescapeText(String s)