Autor Beitrag
Hamster
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 24

Windows XP und Linux SuSe 9.2 sowie 9.1 (Server)
Delphi 7 Enterprise Trial
BeitragVerfasst: Fr 21.01.05 01:51 
Hallo,

ich möchte da was kleines Basteln und habe ne Frage. Ich habe eine HTML Seite, die ich einlese. Nun möcht eich gerne nach einem letzten Vorkommen eines Wertes suchen.

Die Strings nach dem ich suche sehen so aus:

<a name="post178021" id="post178021"></a> bzw "post178021".

So, jetzt meine Frage, wie durchsuche ich die Seite nach dem letzten Vorkommen ?

*kann auch das falsche Forum sein*

_________________
Signatur ist immer gut!
Socher
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 45

warmes flüssiges Blut
D7 Prof, D8 Prof
BeitragVerfasst: Fr 21.01.05 22:30 
Titel: Rückwarts suchen
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
// Vorraussetzung für diese Procedure
// Memo1 ist mit dem Text gefüllt der durchsucht werden soll , also Text vorher in das
// Memo laden oder direkt den String ansprechen
// Im Label1 wird das Ergebnis angezeigt

procedure TForm1.Button1Click(Sender: TObject);
var lges, pos:word;
    Suchstring:string;
    treffer:boolean;
begin
treffer:=false;
Suchstring:='Februar';
lges:=length(memo1.Text)-length(Suchstring);
Pos:=lges;
Label1.Caption:=inttostr(lges);
repeat
if copy(memo1.Text,pos,length(Suchstring))=Suchstring then treffer:=true;
dec(pos,1);
until treffer or (pos=0);
if Treffer then Label1.Caption:='Position im Text '+inttostr(pos)
  else Label1.Caption:='Nichts gefunden'

// Dieser Algo ist wohl der langsamste - es gibt wesentlich schnellere
end;

end.


Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt.

_________________
FREIHEIT