Added code to catch PatternSyntaxExceptions.