Autor Beitrag
k4mi
Hält's aus hier
Beiträge: 6



BeitragVerfasst: Do 05.05.05 14:10 
Hallo,

also ich möchte einen ziemlich langen String nach einer bestimmten Maske durchsuchen.
Im Prinzip zahlxzahlxzahl, wobei zahl eine beliebige zahl zw. 1 und 999 sein kann, und x als
x aufzufassen ist.

ich habe aber keine ahnung wie ich das bewerkstelligen könnte.

danke für eure hilfe
k4mi
chrisw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 439
Erhaltene Danke: 3

W2K
D7
BeitragVerfasst: Fr 06.05.05 06:35 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
var S                          : String;
    zahl1,zahl2,zahl3,position : Integer;
begin
  zahl1 := 12;
  zahl2 := 13;
  zahl3 := 14;
  s :='ABCDEFGH12x13x14xIJKLM'; 
  position :=  pos(IntTostr(zahl1) + 'x' + IntToStr(zahl2) + 'x' + IntToStr(zahl3),s);
  if position <> 0 then Showmessage('Alle Zahlen gefunden an Position : ' + IntTostr(position);   
end;

_________________
Man sollte keine Dummheit zweimal begehen, die Auswahl ist schließlich groß genug.
k4mi Threadstarter
Hält's aus hier
Beiträge: 6



BeitragVerfasst: Fr 06.05.05 13:12 
danke erstmal,

aber ich habe mich wohl uneindeutig ausgedrückt. Es sind beliebige Zahlen, die man auch nicht kennt.

Aber ich schau ma ob ich dein Code umfunktionieren kann ;o

mfg
k.


P.S.: Vllt reicht es auch schon nur Zahlen zu erkennen und mit einer schleife solange abzufragen,ob das nächste Zeichen ein 'x' ist.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Fr 06.05.05 22:26 
Such mal unter dem Stichwort "reguläre Ausdrücke". Ich glaub, da müsstest Du etwas Passendes finden.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
k4mi Threadstarter
Hält's aus hier
Beiträge: 6



BeitragVerfasst: Fr 06.05.05 22:40 
so habs jetzt:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
function ParseCoordinates(const AInputString: string): string;
const
  CoordPattern = '[0-9]+x[0-9]+x[0-9]+';
var
  r : TRegExpr;
begin
  Result := '';
  r := TRegExpr.Create;
  try
    r.Expression := CoordPattern;
    Result := r.Replace(AInputString,'--x---x--');
  finally
    r.Free;
  end;
end;


mfg

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.