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;
/^[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
Post a Comment