Email validation
codephantom
me at noyb.com
Wed Nov 29 02:22:19 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
test/improve it yourself. but you get the idea....
// ----------------------
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";
auto checkDomain = findSplitAfter(emailAddress, "@"); //
requires import std.algorithm
//writeln(checkDomain); // Tuple!(string,
string)("vino.bheeman@", "hotmail.com")
if (checkDomain[1] == domainRequired)
writeln("domain ok");
else
writeln("invalid domain");
}
// ----------------------
More information about the Digitalmars-d-learn
mailing list