public static String basicEscape(String s) {
        char c;
        int len = s.length();
        StringBuilder sbuf = new StringBuilder(len);

        int i = 0;
        while (i < len) {
            c = s.charAt(i++);
            if (c == '\\' && i < len  ) {
                c = s.charAt(i++);
                if (c == 'n') {
                    c = '\n';
                } else if (c == 'r') {
                    c = '\r';
                } else if (c == 't') {
                    c = '\t';
                } else if (c == 'f') {
                    c = '\f';
                } else if (c == '\b') {
                    c = '\b';
                } else if (c == '\"') {
                    c = '\"';
                } else if (c == '\'') {
                    c = '\'';
                } else if (c == '\\') {
                    c = '\\';
                }
                /////
            }
            sbuf.append(c);
        } // while
        return sbuf.toString();
    }
@Test
    public void basicEscape() {
        assertEquals("a", RegularEscapeUtil.basicEscape("a"));
        assertEquals("a\t", RegularEscapeUtil.basicEscape("a\t"));
        assertEquals("a\\", RegularEscapeUtil.basicEscape("a\\"));
        assertEquals("a\\", RegularEscapeUtil.basicEscape("a\\\\"));
    }