Email validation

codephantom me at noyb.com
Wed Nov 29 03:49:56 UTC 2017


On Tuesday, 28 November 2017 at 18:47:06 UTC, Vino wrote:
> Hi All,
>
>  Can you please provide me some example on who to validate an 
> email address as the document dose not have an example for the 
> same
>
> Ex: vino.bheeman at hotmail.com
>
> Conditions :
>
> The domain should contain only "hotmail.com"
> The email address should contain the symbol "@"
>
> From,
> Vino.B


Here's another nice option I just found.

Interestingly, I had to disable Avast antivirus, otherwise when I 
compile it, Avast thinks the exectuable is 'suspicous' and 
prevents any further access to it...wtf?

// ---------------------
module test;

import std.stdio;
import std.algorithm;

/+
CONDITIONS:
     - The domain should contain only "hotmail.com"
     - The email address should contain the symbol "@"
+/

void main()
{
     string domainRequired = "@hotmail.com";

     string emailAddress = "vino.bheeman at hotmail.com";

     emailAddress.endsWith(domainRequired) ? writeln("domain ok")
          : writeln("invalid domain");

}

// --------------------



More information about the Digitalmars-d-learn mailing list