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

Win XP, Suse Linux 11.1
Delphi 5 Prof. Delphi 7 Enterprise Edition
BeitragVerfasst: Sa 13.12.08 17:38 
Hi,

ich versuche gerade mit Pos und PosEx Daten:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
        <td>
      Anzahl:
    </td>
    <td>

      18 //diese zahl möchte ich auslesen
    </td>

hieraus auszulesen.
Mein bisheriger Source:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
Pos1 := Pos('<td>Anzahl</td><td>', Quell)+19;
Pos2 := PosEx('</td>',Quell,Pos1);
filter2 := Copy(Quell,Pos1,Pos2-Pos1);
Label12.Caption := filter2;

ich bekomme aber dann den kompletten script mit anstatt nur die "18"

Danke im Vorraus ;)
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 13.12.08 17:51 
Du vergisst die Leerzeichen und Zeilenumbrüche genauso wie den Doppelpunkt, wenn dein Html-Quelltext oben richtig ist ;-). Dadurch findet Pos nix und Pos1 ist 0 + 19.


Zuletzt bearbeitet von jaenicke am Sa 13.12.08 17:54, insgesamt 1-mal bearbeitet
dekoepke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28

Win XP, Suse Linux 11.1
Delphi 5 Prof. Delphi 7 Enterprise Edition
BeitragVerfasst: Sa 13.12.08 17:54 
sie sind aber mit Tabulator eingerückt... zählt das dann auch wie ein buchstabe oder leerzeichen ?
und wie werden zeilenumbrüchegezählt ?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
Pos1 := Pos('Anzahl:'+#13+'    </td>'+#13+'    <td>', Quell)+7;
Pos2 := PosEx('</td>',Quell,Pos1);
filter2 := Copy(Quell,Pos1,Pos2-Pos1);
Label12.Caption := filter2;
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 13.12.08 17:56 
user profile icondekoepke hat folgendes geschrieben Zum zitierten Posting springen:
sie sind aber mit Tabulator eingerückt... zählt das dann auch wie ein buchstabe oder leerzeichen ?
Tabulator ist das Zeichen #9, der Zeilenumbruch #13#10 (wenn es der von Windows ist). Schau es dir am besten in einem Hexeditor an. ;-)
mh-nexus.de/en/hxd/
dekoepke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28

Win XP, Suse Linux 11.1
Delphi 5 Prof. Delphi 7 Enterprise Edition
BeitragVerfasst: Sa 13.12.08 17:59 
ja das ist klar, aber zählen die dann als 1 wie z.b. a oder zählen die mehr?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 13.12.08 18:11 
Ein Zeichen ist ein Zeichen, wie viele das sind musst du schon selbst schauen, jedes Textverarbeitungsprogramm wie Word zeigt die Zeichen an, wenn man das einstellt. (Strg + *)

Und den Link zu einem Hexeditor habe ich dir auch gepostet, der zeigt dir auch alles an.
dekoepke Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28

Win XP, Suse Linux 11.1
Delphi 5 Prof. Delphi 7 Enterprise Edition
BeitragVerfasst: Sa 13.12.08 18:20 
Vielen Vielen Dank für deine Hilfe ;)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
Pos1 := Pos('Anzahl:'+#10+#9+#9+'</td>'+#10+#9+#9+'<td>'+#10+#9+#9+#9, Quell)+26;
Pos2 := PosEx(#10+#9+#9+'</td>',Quell,Pos1);
filter2 := Copy(Quell,Pos1,Pos2-Pos1);
Label12.Caption := filter2;

So Klappts ;)


Zuletzt bearbeitet von dekoepke am So 11.01.09 22:59, insgesamt 1-mal bearbeitet
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 13.12.08 18:31 
Die ganzen + Zeichen kannst du übrigens auch weglassen, das spart etwas Tipparbeit beim nächsten Mal ;-):
ausblenden Delphi-Quelltext
1:
a := 'Ein String'#10#13#9#9'mit nem Zeilenumbruch und zwei Tabs drin';					
;-)