-3

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

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

I am using below regex. Could anyone verify and suggest to make it short if possible.

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

Thanks in Advance

  • It's unclear what you are asking... – Stuart Sep 11 '17 at 10:28
  • 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) – user3151902 Sep 11 '17 at 10:29
  • Using a regex for email is a bad idea because (1) it's massively complex and (2) it only covers format, meaning there are still a massive number of email addresses which are invalid since they have no backing account behind them. If you want to know if an email address is truly valid (format, exists, has someone monitoring it, etc), send an email to it requiring some action. – paxdiablo Sep 11 '17 at 10:30
  • I edited the question. Please have a look. – Love Sharma Sep 11 '17 at 10:52
  • @paxdiablo I agree with you but when you know regex symbols I think not that difficult. Also, in my case I have set of rules so I am not bother about massive emails of other format. – Love Sharma Sep 20 '17 at 15:14

1 Answers1

0

I checked https://regex101.com/ for understanding my regex and got it.

  • ^([^.])([a-zA-ZA-zàèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ0-9.!#$%&'+=?^_`{|}~/-])+([^.])@[a-zA-ZA-zàèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ0-9]+([a-zA-ZàèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ0-9.-]+([a-zA-Z0-9]))$ – Love Sharma Sep 20 '17 at 15:10