全关系

I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
function ZsMinDivision(mText: string; mSet: TSysCharSet): string; var
I: Integer;
S: string;
B: Boolean;
begin
Result := '';
S := '';
B := False;
for I := 1 to Length(mText) do begin
if B then
if mText in mSet then
S := S + mText
else begin
B := False;
if Length(Result) > Length(S) then
Result := S
end
else if mText in mSet then begin
B := True;
S := mText;
end;
end;
if B and (Length(Result) > Length(S)) then Result := S;
end; { ZsMinDivision }
function ZsMaxDivision(mText: string; mSet: TSysCharSet): string;
var
I: Integer;
S: string;
B: Boolean;
begin
Result := '';
S := '';
B := False;
for I := 1 to Length(mText) do begin
if B then
if mText in mSet then
S := S + mText
else begin
B := False;
if Length(Result) < Length(S) then
Result := S
end
else if mText in mSet then begin
B := True;
S := mText;
end;
end;
if B and (Length(Result) < Length(S)) then Result := S;
end; { ZsMaxDivision }
function ZsPort(mText: string): string; { 全关系 }
procedure pZsPort(mText: string);
var
vLeft, vRight: string;
S: string;
I, L: Integer;
vText: string;
begin
S := ZsMaxDivision(mText, [#0..#255] - ['(', '|', ')']);
L := Length(S);
if L <= 1 then
Result := Result + mText + #13#10
else for I := 1 to L - 1 do begin
vLeft := Copy(S, 1, I);
vRight := Copy(S, I + 1, L);
vText := mText;
vText := StringReplace(vText, S, Format('(%s|%s)', [vLeft, vRight]), [rfReplaceAll]);
pZsPort(vText);
end;
end;
begin
Result := '';
pZsPort(mText);
end; { ZsPort }
 
 

Similar threads

A
回复
0
查看
832
Andreas Hausladen
A
S
回复
0
查看
588
SUNSTONE的Delphi笔记
S
S
回复
0
查看
590
SUNSTONE的Delphi笔记
S
S
回复
0
查看
603
SUNSTONE的Delphi笔记
S
S
回复
0
查看
577
SUNSTONE的Delphi笔记
S
顶部