Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Pos info ??? (https://www.delphipraxis.net/36150-pos-info.html)

Gigant02 16. Dez 2004 14:03


Pos info ???
 
kann ich pos sagen das er erst ab einer gewissen stelle sucht ???

lg, Gigant02

SubData 16. Dez 2004 14:06

Re: Pos info ???
 
Delphi-Referenz durchsuchenPosEx :>

sakura 16. Dez 2004 14:18

Re: Pos info ???
 
@SubData: Falsch, gibt es in Delphi 5 noch nicht :roll: Aber in der CodeLib findest Du diesen Beitrag.

...:cat:...

MaBuSE 16. Dez 2004 14:19

Re: Pos info ???
 
Zitat:

Zitat von Gigant02
kann ich pos sagen das er erst ab einer gewissen stelle sucht ???

PosEx aus der Unit StrUtils, oder falls PosEx nicht eingesetzt werden soll kann man sich das mit einem Copy basteln ;-)
Delphi-Quellcode:
  substr := 'A';
  s := 'ABCABC';
  Anfang := 2;
  i := pos(substr, copy(s, Anfang, length(s)));
  j := i + Anfang - 1;
  // i = 3 weil pos('A','BCABC') = 3;
  // j = 4 weil das 2. A in 'ABCABC' an der 4. Stelle ist

SubData 16. Dez 2004 14:21

Re: Pos info ???
 
:wall: Ich sollte mir angewöhnen auf die Delphi Versionen zu achten...

Aber die Lösung mit dem Copy ist natürlich auch gut :)

sakura 16. Dez 2004 14:24

Re: Pos info ???
 
Zitat:

Zitat von MaBuSE
PosEx aus der Unit StrUtils, oder falls PosEx nicht eingesetzt werden soll kann man sich das mit einem Copy basteln ;-)

Mache das mal mit einem 5 MB String :shock: Das wird laaaaangsam :roll:

...:cat:...

Gigant02 16. Dez 2004 14:25

Re: Pos info ???
 
die löhsung mit dem Copy ist sehr gut die hat mir weiter geholfen


besten dank

MaBuSE 16. Dez 2004 14:27

Re: Pos info ???
 
Zitat:

Zitat von sakura
@SubData: Falsch, gibt es in Delphi 5 noch nicht :roll: Aber in der CodeLib findest Du diesen Beitrag.

Cool ASM.

Der Orginal Quelltext von Borland sieht so aus:
Delphi-Quellcode:
{ *********************************************************************** }
{ Delphi Runtime Library                                                 }
{ Copyright (c) 1995-2001 Borland Software Corporation                   }
{ *********************************************************************** }
...
{ PosEx searches for SubStr in S and returns the index position of
  SubStr if found and 0 otherwise. If Offset is not given then the result is
  the same as calling Pos. If Offset is specified and > 1 then the search
  starts at position Offset within S. If Offset is larger than Length(S)
  then PosEx returns 0. By default, Offset equals 1. }
...
function PosEx(const SubStr, S: string; Offset: Cardinal = 1): Integer;
var
  I,X: Integer;
  Len, LenSubStr: Integer;
begin
  if Offset = 1 then
    Result := Pos(SubStr, S)
  else
  begin
    I := Offset;
    LenSubStr := Length(SubStr);
    Len := Length(S) - LenSubStr + 1;
    while I <= Len do
    begin
      if S[I] = SubStr[1] then
      begin
        X := 1;
        while (X < LenSubStr) and (S[I + X] = SubStr[X + 1]) do
          Inc(X);
        if (X = LenSubStr) then
        begin
          Result := I;
          exit;
        end;
      end;
      Inc(I);
    end;
    Result := 0;
  end;
end;
...

Treffnix 16. Dez 2004 14:33

Re: Pos info ???
 
Darf man das so einfach online stellen? Is das nicht copyrighted?

SubData 16. Dez 2004 14:37

Re: Pos info ???
 
Denke mal solange es Delphi Intern bleibt, wird da keiner was sagen :)


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:50 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz