added try-catch for Pattern.compile unchecked exception