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[I] in mSet then
S := S + mText[I]
else begin
B := False;
if Length(Result) > Length(S) then
Result := S
end
else if mText[I] in mSet then begin
B := True;
S := mText[I];
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[I] in mSet then
S := S + mText[I]
else begin
B := False;
if Length(Result) < Length(S) then
Result := S
end
else if mText[I] in mSet then begin
B := True;
S := mText[I];
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 }