private static final String NAME_REGEX = "^[a-zA-Z]+(([',. -][a-zA-Z ])?[a-zA-Z]*)*$";
private static final Pattern NAME_PATTERN = Pattern.compile(NAME_REGEX);
how do I use the following statement in try n catch block to chk if the name is valid and display error msg if any?
NAME_PATTERN.matcher(name).matches()
and how to use PatternSyntaxException