...einen String auf eine gültige Email Adresse überprüfen?
|
Autor:
Ollo Heß |
[ Tip ausdrucken ] | | |
function MailURLMayBeInvalid(const s: string): Boolean;
var
i: Integer;
c: string;
begin // ' ', ä, ö, ü, ß, [, ], (, ), : in EMail-Address
Result := (Trim(s) = '') or (Pos(' ', AnsiLowerCase(s)) > 0) or
(Pos('ä', AnsiLowerCase(s)) > 0) or (Pos('ö', AnsiLowerCase(s)) > 0) or
(Pos('ü', AnsiLowerCase(s)) > 0) or (Pos('ß', AnsiLowerCase(s)) > 0) or
(Pos('[', AnsiLowerCase(s)) > 0) or (Pos(']', AnsiLowerCase(s)) > 0) or
(Pos('(', AnsiLowerCase(s)) > 0) or (Pos(')', AnsiLowerCase(s)) > 0) or
(Pos(':', AnsiLowerCase(s)) > 0);
if Result then Exit; // @ not in EMail-Address;
i := Pos('@', s);
Result := (i = 0) or (i = 1) or (i = Length(s));
if Result then Exit;
Result := (Pos('@', Copy(s, i + 1, Length(s) - 1)) > 0);
if Result then Exit; // Domain <= 1
c := Copy(s, i + 1, Length(s));
Result := Length(c) <= 1;
if Result then Exit;
i := Pos('.', c);
Result := (i = 0) or (i = 1) or (i = Length(c));
end;
Bewerten Sie diesen Tipp:
|
|
|