Regex was born for this kind of work. Here's a minimal console application that shows how you can use RegEx to extract all email addresses from one long block of text:
program Project25;
{$APPTYPE CONSOLE}
uses
SysUtils, PerlRegex;
var PR: TPerlRegEx;
TestString: string;
begin
TestString := '<one@server.domain.xy>, another@otherserver.xyz';
PR := TPerlRegEx.Create;
try
PR.RegEx := '\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b';
PR.Options := PR.Options + [preCaseLess];
PR.Compile;
PR.Subject := TestString;
if PR.Match then
begin
WriteLn(PR.MatchedText);
while PR.MatchAgain do
WriteLn(PR.MatchedText);
end;
finally PR.Free;
end;
Readln;
end.
. , XE Delphi:
http://www.regular-expressions.info/delphi.html