Проверить строку на правильность Email адреса
Оформил: DeeCo
Автор: http://www.swissdelphicenter.ch
function MailURLMayBeInvalid(const s: string): Boolean;
var
i: Integer;
c: string;
begin // ' ', a, o, u, ?, [, ], (, ), : in EMail-Address
Result := (Trim(s) = '') or (Pos(' ', AnsiLowerCase(s)) > 0) or
(Pos('a', AnsiLowerCase(s)) > 0) or (Pos('o', AnsiLowerCase(s)) > 0) or
(Pos('u', 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;
|