An easier solution.

if ("(<{[".indexOf(string.charAt(position)) >= 0) {
blah blah
}