Skip to content

Instantly share code, notes, and snippets.

@vpilot
Last active August 29, 2015 13:56
Show Gist options
  • Save vpilot/8919471 to your computer and use it in GitHub Desktop.
Save vpilot/8919471 to your computer and use it in GitHub Desktop.
Regex Tips
// email validation, supports only lower case emails
@Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\."
+"[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@"
+"(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",
message="Invalid Email")
protected String email;
// not blank
@NotNull(message="Title can not be NULL.")
@Pattern(regexp="^(?!\\s*$).+", message="Title can not be empty.")
private String title;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment