public static String removeEscapeChars ( String origKey ) { StringBuilder sb = new StringBuilder ( ) ; boolean prevWasEscape = false ; for ( char c : origKey . toCharArray ( ) ) { if ( ' ' == c ) { if ( prevWasEscape ) { sb . append ( c ) ; prevWasEscape = false ; } else { prevWasEscape = true ; } } else { sb . append ( c ) ; prevWasEscape = false ; } } return sb . toString ( ) ; }
given rating \\ pants - > rating \ pants escape the escape char