AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

String an bestimmtem Zeichen Splitten

Ein Thema von cRayZo · begonnen am 20. Aug 2008 · letzter Beitrag vom 22. Aug 2008
 
hathor
(Gast)

n/a Beiträge
 
#4

Re: String an bestimmtem Zeichen Splitten

  Alt 20. Aug 2008, 16:55
Delphi-Quellcode:
function SplitStr(const S: string; Delim: Char; out S1, S2: string): Boolean;
  {Splits the string S at the first occurence of delimiter character Delim and
  sets S1 to the sub-string before Delim and S2 to substring following Delim.
  If Delim is found in string True is returned, while if Delim is not in string
  False is returned, S1 is set to S and S2 is set to ''.}

var
  DelimPos: Integer; // position of delimiter in source string
begin
  // Find position of first occurence of delimter in string
  DelimPos := SysUtils.AnsiPos(Delim, S);
  if DelimPos > 0 then
  begin
    // Delimiter found: do split and return True
    S1 := Copy(S, 1, DelimPos - 1);
    S2 := Copy(S, DelimPos + 1, MaxInt);
    Result := True;
  end
  else
  begin
    // Delimeter not found: return false and set S1 to whole string
    S1 := S;
    S2 := '';
    Result := False;
  end;
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:32 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz