Java String Quote Unescape unescapeSingleQuoteAndBackslash(String str)

Here you can find the source of unescapeSingleQuoteAndBackslash(String str)

Description

unescape Single Quote And Backslash

License

Open Source License

Declaration

public static String unescapeSingleQuoteAndBackslash(String str) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009-2013 CWI/*from w  ww.  jav a2  s.c o  m*/
 * 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:
    
 *   * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI
 *   * Tijs van der Storm - Tijs.van.der.Storm@cwi.nl
*******************************************************************************/

public class Main {
    public static String unescapeSingleQuoteAndBackslash(String str) {
        char[] chars = str.toCharArray();
        StringBuffer result = new StringBuffer();

        for (int i = 0; i < chars.length; i++) {
            char b = chars[i];
            switch (b) {
            case '\\':
                switch (chars[++i]) {
                case '\\':
                    b = '\\';
                    break;
                case '\'':
                    b = '\'';
                    break;
                }
            }
            result.append(b);
        }
        return result.toString();
    }
}

Related

  1. unescapeQuotes(final String text)
  2. unescapeQuotes(String text)
  3. unescapeQuotes(String value)
  4. unescapeQuotesAndBackSlash(String path, boolean isSingleQuoteUnescape)
  5. unescapeQuotesWithBackslash(final String value)