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.bhee...@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.bhee...@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");
}
// ----------------------