It would be substantially faster to check exp.charAt(0) === ':' && exp.charAt(1) === ';' unless there is some reason we care if :: occurs later in the string.