Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Extract And Validating Email Addresses Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
29-Oct-02
Category
Object Pascal-Strings
Language
Delphi 5.x
Views
97
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Abu Zant Ruslan

This code example introduces a new way to validate Email Addresses with domain name 
(TLD) validation !!

Answer:

Code #1

1   function IsEMail(EMail: string): Boolean;
2   var
3     s: string;
4     ETpos: Integer;
5   begin
6     ETpos := pos('@', EMail);
7     if ETpos > 1 then
8     begin
9       s := copy(EMail, ETpos + 1, Length(EMail));
10      if (pos('.', s) > 1) and (pos('.', s) < length(s)) then
11        Result := true
12      else
13        Result := false;
14    end
15    else
16      Result := false;
17  end;
18  
19  procedure TForm1.Button1Click(Sender: TObject);
20  begin
21    if isemail(Edit1.Text) then
22    begin
23      ShowMessage('eMail-Adresse!');
24    end;
25  end;



Code #2

26  MaxDomains = 174;
27  
28  DomainList: array[0..MaxDomains] of string[3] = (
29    'AD', 'AE', 'AG', 'AI', 'AM', 'AR', 'AS', 'AT', 'AU', 'AW', 'AZ', 'BA', 'BE', 
30  'BF',
31    'BG', 'BH', 'BM', 'BN', 'BO', 'BR', 'BS', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CH', 
32  'CI',
33    'CK', 'CL', 'CN', 'CO', 'COM', 'CR', 'CU', 'CY', 'CZ', 'DE', 'DK', 'DM', 'DO', 
34  'DZ',
35    'EC', 'EDU', 'EE', 'EG', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GB', 
36  'GE',
37    'GF', 'GH', 'GI', 'GL', 'GOV', 'GR', 'GT', 'GU', 'GW', 'GY', 'HK', 'HN', 'HR', 
38  'HU',
39    'ID', 'IE', 'IL', 'IN', 'INT', 'IO', 'IR', 'IS', 'IT', 'JM', 'JO', 'JP', 'KE', 
40  'KG',
41    'KH', 'KI', 'KM', 'KR', 'KW', 'KY', 'KZ', 'LB', 'LI', 'LK', 'LT', 'LU', 'LV', 
42  'MA',
43    'MC', 'MD', 'MIL', 'MK', 'MN', 'MO', 'MR', 'MT', 'MU', 'MV', 'MX', 'MY', 'MZ', 
44  'NA',
45    'NC', 'NE', 'NET', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NU', 'NZ', 'OM', 'ORG',
46    'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PR', 'PT', 'PY', 'QA', 'RO', 'RU', 
47  'SA',
48  	'SE', 'SG', 'SI', 'SK', 'SL', 'SM', 'SN', 'ST', 'SU', 'SV', 'SZ', 'TC', 'TF', 'TG',
49    'TH', 'TM', 'TO',  'TR', 'TT', 'TW', 'TZ', 'UA', 'UG', 'UK', 'US', 'UY', 'UZ', 
50  'VA',
51    'VE', 'VI', 'VN',  'YE', 'YU', 'ZA', 'ZM', 'ZW');
52  
53  function InDomainList(email: string): boolean;
54  
55  var
56    tel: word;
57    st: string;
58  
59  begin
60    tel := length(email);
61    while (tel > 0) and (email[tel] <> '.') do
62      dec(tel);
63    st := copy(email, tel + 1, length(email));
64  
65    for tel := 0 to maxdomains do
66      if st = DomainList[tel] then
67      begin
68        InDomainList := true;
69        inc(hittable[tel]);
70        exit;
71      end;
72    InDomainList := false;
73  end;



Have Fun !!!

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC