function GetModalStr(mStr: string; mModalStrList: array of TModalStr;
mSingles: TIntegerSet): string;
var
vSingle: Integer;
I, J: Integer;
T, K: Integer;
vEnd: string;
vAppend: string;
begin
Result := '';
vSingle := 0;
T := 0;
K := 0;
for I := 1 to Length(mStr) do begin
if T > 1 then begin
Dec(T);
Continue;
end;
if vSingle = 0 then begin
vEnd := '';
for J := Low(mModalStrList) to High(mModalStrList) do begin
K := Length(mModalStrList[J].rBegin);
if Copy(mStr, I, K) = mModalStrList[J].rBegin then begin
vEnd := mModalStrList[J].rEnd;
vAppend := mModalStrList[J].rAppend;
vSingle := mModalStrList[J].rSingle;
if vSingle in mSingles then
Result := Result + mModalStrList[J].rBegin;
T := K;
K := Length(vEnd);
Break;
end;
end;
if (vEnd = '') and (vSingle in mSingles) then
Result := Result + mStr[I];
end else if Copy(mStr, I, K) = vEnd then begin
if vSingle in mSingles then
Result := Result + vEnd
else Result := Result + vAppend;
vSingle := 0;
T := K;
end else if vSingle in mSingles then
Result := Result + mStr[I];
end;
end; { GetModalStr }