Autor Beitrag
martin121
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28



BeitragVerfasst: Sa 10.04.04 15:17 
Hallo,
ich bräuchte mal etwas Hilfe.
Ich habe folgendes Problem:
Der String
#xyz#sda#wr#safd
soll zum Beispiel zu
#xyz#sda#wr
werden.
Nur das Problem ist das sich die Buchstaben ändern können lediglich die Route ist immer vorhanden und die letzte Route mit dem darauffolgenem Text soll entfernt werden.
Gibts da irgendeine funktion oder sowas?
Danke für eure Hilfe, Martin.
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Sa 10.04.04 15:40 
hi,

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var
   i: Integer;
begin
   i := Length(derstring);
   while (i>0) and (derstring[i] <> '#') do
      dec(i);
   derstring := Copy(derstring, 1, i-1);
end;


raziel

_________________
JSXGraph
MartinPb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 698



BeitragVerfasst: Sa 10.04.04 15:47 
Mit Pos ermitelst du das erste vorkommen eines Suchstrings. Mit LastDelimiter ermittelst du das letzte Vorkommen eines Suchstrings. Also:

a := LastDelimiter('#', DeinString);

gibt die letzte Position der Raute.

Mit der Prozedur, nicht Funktion, Delete kannst du etwas abschneiden.

Delete(DeinString, a, Length(DeinString) - a + 1);

_________________
Gruß
Martin
martin121 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28



BeitragVerfasst: Sa 10.04.04 15:51 
Danke für euere Hilfe,
werde gleich mal ausprobieren

//edit: Danke, es hat funktioniert