Autor Beitrag
nano
Hält's aus hier
Beiträge: 14



BeitragVerfasst: Mi 08.12.04 19:57 
hallo,
ich habe ein memo, in dem ich einen text mit "copy&past" einfügen will/kann. so, nun will ich, das er mir aus diesen text bestimmte wörter zählen tut. z.b. das wort "hallo". und als ausgabe dann so was wie: das wort "hallo" kommt "x" mal vor.
hat diesbezüglich einer eine einfache lösung?
mfg
nano
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Mi 08.12.04 20:09 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var
  a : Integer;
  s, t : string;
begin
  a:=0;
  s:=Memo.Text;
  t:='hallo';
  while Pos(t,s) > 0 do
  begin
    Inc(a);
    s:=Copy(s,Pos(t,s)+Length(t),Length(s));
  end;

Gruß,
Jörg

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
nano Threadstarter
Hält's aus hier
Beiträge: 14



BeitragVerfasst: Mi 08.12.04 20:20 
merci noch ma :beer:
wunsiedler
ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 506
Erhaltene Danke: 4

Win7

BeitragVerfasst: Mi 15.12.04 16:07 
bei mir ist

t:='http://cgi1.ebay.de/aw-cgi/eBayISAPI.dll?ViewItemWithCategory&item=';

und in s ist html code einer seite. variablentypen sind die gleichen

als ergebnis von pos bekomm ich immer 0

der gesuchte string befindet sich aber zu 100% im html-text

warum?
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Mi 15.12.04 16:17 
wunsiedler hat folgendes geschrieben:

bei mir ist

t:='http://cgi1.ebay.de/aw-cgi/eBayISAPI.dll?ViewItemWithCategory&item=';

[...]


Groß-/Kleinschreibung beachtet?

mfg

Alstar
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Mi 15.12.04 16:18 
wunsiedler hat folgendes geschrieben:

als ergebnis von pos bekomm ich immer 0

der gesuchte string befindet sich aber zu 100% im html-text


Delphihilfe:
Ist Substr nicht vorhanden, wird der Wert Null zurückgegeben.


tut mir leid, aber ich glaube eher Pos, wenn ich keinen text habe :roll:

;)

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
wunsiedler
ontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 506
Erhaltene Danke: 4

Win7

BeitragVerfasst: Mi 15.12.04 16:22 
habs geändert. Das '&' in der url ist schuld. Kann man das irgendwie in den Griff bekommen?
matze.de
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 576

Win95, Win98 SE, WinXp Prof SP2
D7P, D8P, FPC2.0
BeitragVerfasst: Mi 15.12.04 16:24 
probiers mal mit "&" statt "&"

mfg matze

_________________
si tacuisses, philosophus mansisses.
Alstar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 827



BeitragVerfasst: Mi 15.12.04 16:24 
Probier es doch mal mit dem ASCII-Code einzubinden:

ausblenden Delphi-Quelltext
1:
t := '...'+#38+'...';					


Alstar
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Mi 15.12.04 16:24 
wunsiedler hat folgendes geschrieben:
habs geändert. Das '&' in der url ist schuld. Kann man das irgendwie in den Griff bekommen?


komisch... gehts mit '&&' ?

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)