String (String text) { final StringBuilder newExpression = new StringBuilder(); boolean escaped = false; final int length = text.length(); for (int i = 0; i < length; i++) { final char c = text.charAt(i); if (escaped) { if (c != '\'') newExpression.append('\\'); newExpression.append(c); escaped = false; } else if (c == '\\') { escaped = true; } else { newExpression.append(c); } } return newExpression.toString(); }