FUNCTION IsValidEmail(CONST Value: String): boolean;
FUNCTION CheckAllowed(CONST s: String): boolean;
VAR i: Integer;
BEGIN
Result:= False;
FOR i:= 1 TO Length(s) DO // illegal char in s -> no valid address
IF NOT (s[i] IN ['a'..'z','A'..'Z','0'..'9','_','-','.']) THEN Exit;
Result:= true;
END;
VAR
i,len: Integer;
namePart, serverPart: String;
BEGIN // of IsValidEmail
Result:= False;
i:= Pos('@', Value);
IF (i=0) OR (Pos('..',Value) > 0) THEN Exit;
namePart:= Copy(Value, 1, i - 1);
serverPart:= Copy(Value,i+1,Length(Value));
len:=Length(serverPart);
// must have dot and at least 3 places from end, 2 places from begin
IF (len<4) OR
(Pos('.',serverPart)=0) OR
(serverPart[1]='.') OR
(serverPart[len]='.') OR
(serverPart[len-1]='.') THEN Exit;
Result:= CheckAllowed(namePart) AND CheckAllowed(serverPart);
END;
//Sample call (put a button1 and a edit1)
procedure TForm1.Button1Click(Sender: TObject);
begin
if IsValidEmail(edit1.Text) = true then
Showmessage('The email is valid')
else
Showmessage('The email is not valid!!');
end;
That’s really thinking out of the box. Tnakhs!
Wham bam thank you, ma’am, my questions are answeerd!
Perfect answer! That rlaely gets to the heart of it!
My pbrolem was a wall until I read this, then I smashed it.
Keep these articles cmnoig as they’ve opened many new doors for me.
That’s the best answer by far! Thanks for contrbiutnig.
Stelalr work there everyone. I’ll keep on reading.
My problem was a wall until I read this, then I smsaehd it.
The genius store called, they’re runinng out of you.
This is a really intelligent way to awnser the question.
Is that really all there is to it becuase that’d be flabbergasting.
If only there were more clveer people like you!
Inetlligecne and simplicity – easy to understand how you think.
I supsope that sounds and smells just about right.
Stands back from the keoybard in amazement! Thanks!
AFAICT you’ve covered all the bases with this anwesr!
Alakzaaam-information found, problem solved, thanks!
Your thinking macehts mine – great minds think alike!
Me dull. You smart. That’s just what I nedeed.
It’s much easier to uendrstnad when you put it that way!
Me and this article, stiintg in a tree, L-E-A-R-N-I-N-G!
Thanks for the inshigt. It brings light into the dark!
Do you have more great atrilecs like this one?
At last, smoenoe who knows where to find the beef
helpful task for bringing an item new with the online world!
I’m impressed. You’ve rlealy raised the bar with that.
I leitrally jumped out of my chair and danced after reading this!
The accident of fniidng this post has brightened my day
Fidnnig this post solves a problem for me. Thanks!
Articles like this really grease the shafts of knowldgee.
Leaninrg a ton from these neat articles.
Way to use the internet to help people solve porlbems!
Help, I’ve been ifnomred and I can’t become ignorant.
This post has helped me think things trhuogh
Stellar work there eevryone. I’ll keep on reading.