c = readChar();
switch (c) {
case '0':
c = readChar();
if (c < '0' || c > '3') {
throw new RegExpException(
RegExpException.UNSUPPORTED_ESCAPE_CHARACTER,
pos - 3,
pattern);
}
str = String.valueOf(c);
c = (char) peekChar(0);
if ('0' <= c && c <= '7') {
str += String.valueOf(readChar());
c = (char) peekChar(0);
if ('0' <= c && c <= '7') {
str += String.valueOf(readChar());
}
}
try {
return (char) Integer.parseInt(str, 8);
} catch (NumberFormatException e) {
throw new RegExpException(
RegExpException.UNSUPPORTED_ESCAPE_CHARACTER,
pos - str.length() - 2,
pattern);
}
case 'x':
str = String.valueOf(readChar()) +
String.valueOf(readChar());
try {
return (char) Integer.parseInt(str, 16);
} catch (NumberFormatException e) {
throw new RegExpException(
RegExpException.UNSUPPORTED_ESCAPE_CHARACTER,
pos - str.length() - 2,
pattern);
}
case 'u':
str = String.valueOf(readChar()) +
String.valueOf(readChar()) +
String.valueOf(readChar()) +
String.valueOf(readChar());
try {
return (char) Integer.parseInt(str, 16);
} catch (NumberFormatException e) {
throw new RegExpException(
RegExpException.UNSUPPORTED_ESCAPE_CHARACTER,
pos - str.length() - 2,
pattern);
}
case 't':
return '\t';
case 'n':
return '\n';
case 'r':
return '\r';
case 'f':
return '\f';
case 'a':
return '\u0007';
case 'e':
return '\u001B';
default:
if (('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z')) {
throw new RegExpException(
RegExpException.UNSUPPORTED_ESCAPE_CHARACTER,
pos - 2,
pattern);
}
return c;