E-mail address regex / regexp pattern

The whole e-mail address regexp pattern thing is much more complex than just a .*@.* and there are a lot of different variations. However this one is the HTML5 spec regex pattern:

/^[a-zA-Z0-9.!#$%&'*+/=?\^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/

...as of 2012-01-10. It works well together with RequestFactory's onConstraintViolation.

@Pattern(
message = "Invalid mail address.",
regexp = "^[a-zA-Z0-9.!#$%&'*+/=?\\^_`{|}~-]+@[a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)*$"
)
private String mail;

Comments

Popular posts from this blog

Tuning ext4 for performance with emphasis on SSD usage

Java 8: Default Interface Implementations, The Diamond Problem, Multiple Inheritance, and Precedence

Tuning ext3 for performance without losing its data integrity potential