Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PosAll(s, str: string): array of Integer;
- var
- sL, strL, o, p, r: Integer;
- begin
- sL := Length(s);
- strL := Length(str);
- if (sL > strL) then
- Exit;
- SetLength(Result, strL);
- repeat
- p := PosEx(s, str, (o + 1));
- if (p > 0) then
- begin
- Result[r] := p;
- o := p;
- Inc(r);
- end;
- until (p <= 0);
- SetLength(Result, r);
- end;
- var
- s, str: string;
- TIA: array of Integer;
- h, i: Integer;
- begin
- ClearDebug;
- str := '|||| PosAll() Test ||| *** ||| Should work pretty well. ||||';
- s := '||';
- TIA := PosAll(s, str);
- h := High(TIA);
- if (h < 0) then
- Exit;
- str := '"' + s + '" positions in str: ';
- for i := 0 to h do
- if (i < h) then
- str := str + IntToStr(TIA[i]) + ', '
- else
- str := str + IntToStr(TIA[i]) + '.';
- WriteLn(str);
- SetLength(TIA, 0);
- end.
Advertisement
Add Comment
Please, Sign In to add comment