Код:
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 | procedure FindWords;
var
C, S, W: string ;
Q: Boolean ;
P, I: Integer ;
begin
Edit3 . Clear;
S := Edit1 . Text;
C := Edit2 . Text;
W := '' ;
P := Pos(C, S);
Q := P > 0 ;
while Q do
begin
W := C;
I := P - 1 ;
while (I > 0 ) and (S[i] <> ' ' ) do
begin
W := S[i] + W;
Dec(I);
end ;
I := P + 1 ;
while (I <= Length(S)) and (S[i] <> ' ' ) do
begin
W := W + S[i];
Inc(I);
end ;
Edit3 . Text := Edit3 . Text + W + ', ' ;
S := Copy(S, I, Length(S));
P := Pos(C, S);
Q := P > 0 ;
end ;
end ;
|
Вот, как-то так наверно, не проверял, конечно.