Einzelnen Beitrag anzeigen

Hawkeye219

Registriert seit: 18. Feb 2006
Ort: Stolberg
2.227 Beiträge
 
Delphi 2010 Professional
 
#6

Re: TStringList, Delimiter='@'

  Alt 19. Dez 2008, 16:56
Hallo Heiko,

für den Spezialfall der Trennung an einer Stelle hätte ich noch einen Vorschlag:

Delphi-Quellcode:
function SplitString (
           const aSource : string;
           const aSeparator : string;
             var aBefore : string;
             var aAfter : string
         ) : Boolean;
var
  Position : Integer;
begin
  Position := Pos(aSeparator, aSource);
  Result := (Position > 0);

  if (not Result) then
    Position := Length(aSource) + 1;

  aBefore := Copy(aSource, 1, Position - 1);
  aAfter := Copy(aSource, Position + Length(aSeparator), MaxInt);
end;

// Anwendung

var
  sID, sName : string;
begin
  SplitString('12345@Tricor Packaging & Logistics AG', '@', sID, sName);
end;
Gruß Hawkeye
  Mit Zitat antworten Zitat