-7

My regex is not working for below mention emails. Please help Regex ^[a-zA-ZA-zÀ-ÖØ-öø-ÿäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ0-9!#$%&'+/=?^_{|}~-]+(.[a-zA-ZÀ-ÖØ-öø-ÿäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ0-9!#$%&'*+\/=?^_{|}~]+)@(?:[a-zA-ZA-zÀ-ÖØ-öø-ÿäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ0-9]+.(?:[a-z0-9-]*[a-z0-9])?.)+a-z0-9?$

Email not working localpart@domain not showing error. Valid email is localpart@domain.com

domain.domain not showing error. (@ and local part missing)

localSpecialCharacters!#$%&'*+-/=?^_`{|}~@domain.domain This should not display error but it is showing invalid email error.

Invalid€character@domain.domain not showing error but it should as € not allowed.

localpart@ àèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ.domain This is also not working

Thanks for help in advance.

  • 1
    Possible duplicate of [Using a regular expression to validate an email address](https://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address) – Ivar Sep 18 '17 at 07:20
  • `(?:[a-z0-9!#$%&'*+/=?^_\`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_\`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])` – ctwheels Sep 18 '17 at 16:18
  • Thanks for your reply but this regex is taking spaces in local part. Also working for special characters like (,),<,> and many other conditions I don't want.. – Love Sharma Sep 20 '17 at 06:45
  • @Ivar As per my rules I don't think there is regex in question you provided. – Love Sharma Sep 20 '17 at 15:07

1 Answers1

0

I was having specific rules for my requirement. I found the correct regex for my problem i.e. ^([^.])([a-zA-ZA-zàèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ0-9.!#$%&'+=?^_`{|}~/-])+([^.])@[a-zA-ZA-zàèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ0-9]+([a-zA-ZàèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ0-9.-]+([a-zA-Z0-9]))$

Rules were For Email local part:
1) Latin letters are allowed: A to Z and a to z
2) Number are allowed: 0 to 9
3) Following special characters are allowed: !#$%&'*+-/=?^_{|}~<br> 4) Dot “.” is allowed but must not be the first or the last character and two dots must not appear consecutively.<br> 5) Following Latin characters with diacritics are allowed: àèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ<br> 6) Other Latin characters are not allowed including special character other than !#$%&'*+-/=?^_{|}~
7) 64 characters length maximum

Email domain must match the requirements for a hostname,
1) a list of dot-separated DNS labels, each label being limited to a length of 63 characters and with the following rules:
2) Latin letters are allowed: A to Z and a to z
3) Number are allowed: 0 to 9
4) Hyphen “-“ is allowed but must not be the first or the last character
5) Following Latin characters with diacritics are allowed: àèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ
6) Other characters are not allowed
7) Total email address: 256 characters length maximum