Herzlich Willkommen in der Delphi-PRAXiS.
Zu Fuß geht es auch - so oder ähnlich:
Delphi-Quellcode:
const
LC_CHARS = '
abcdefghijklmnopqrstuvwxyz';
UC_CHARS = '
ABCDEFGHIJKLMNOPQRSTUVWXYZ';
ValidMailBoxChars = LC_CHARS + UC_CHARS + '
.';
procedure ExtractMailAddr(text:
String; s: TStrings);
var
iSearch, iStart: Integer;
sAddr:
String;
begin
s.Clear;
iSearch := 1;
while iSearch < Length(text)
do
begin
sAddr := '
';
iStart := PosEx('
@', text, iSearch);
if iStart = 0
then Exit;
iSearch := iStart;
while (iStart > 1)
and (Pos(text[Pred(iStart)], ValidMailBoxChars) > 0)
do
Dec(iStart);
while (iSearch < Length(text))
and (Pos(text[Succ(iSearch)], ValidMailBoxChars) > 0)
do
Inc(iSearch);
s.Add(Copy(text, iStart, Succ(iSearch - iStart)));
Inc(iSearch);
end;
end;
Grüße vom marabu