I know this question has been asked many times but my question is different from others. Currently, I am using below regex for validating email address but there is a case when I test for .com.com multiple times it accepts. I want to a regex that also test for multiple .com or multiple .in . is that possible? Or should I handle this programmatically like I split whole string with expression “.” And check for array length. If length is greater that 1 it means multiple . com/.in exists and should not validate? The regex I am using is below
String regExpn =
"^(([\\w-]+\\.)+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|([a-zA-Z]+[\\w-]+\\.)+[a-zA-Z]{2,4})$";