0

image

I have used email and web validation . for email I am using below code

@Size(min = 1, max = 191)
@Pattern(regexp = "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$")
private String email;

//for web address validation I have used following expression

@Size(min = 1, max = 191)
@Pattern(regexp = "^(https?:\\/\\/)?([\\w\\.]+)\\.([a-z]{2,6}\\.?)(\\/[\\w\\.]*)*\\/?$")
private String webAddress;
Vish Garad
  • 17
  • 6
  • similar question https://stackoverflow.com/q/66532068/7804477 – Gautham M Jun 02 '21 at 08:04
  • Does this answer your question? [What is the best regular expression to check if a string is a valid URL?](https://stackoverflow.com/questions/161738/what-is-the-best-regular-expression-to-check-if-a-string-is-a-valid-url) Also for email address validation try using `@Email` instead of `@Pattern` – Gautham M Jun 02 '21 at 08:10

0 Answers0