Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function StrPosAllTCA(TCA: array of Char; str: string): TIntArray;
- var
- h, h2, i, i2, i3, d, o, p, r: Integer;
- begin
- h := High(TCA);
- if ((h < 0) or (str = '')) then
- Exit;
- if (h >= 1) then
- for i := (h - d) downto 1 do
- for i2 := (i - 1) downto 0 do
- if (TCA[i] = TCA[i2]) then
- begin
- h2 := High(TCA);
- for i3 := i to (h2 - 1) do
- TCA[i3] := TCA[(i3 + 1)];
- SetLength(TCA, h2);
- Inc(d);
- Break;
- end;
- h := High(TCA);
- SetLength(Result, Length(str));
- for i := 0 to h do
- begin
- repeat
- p := PosEx(TCA[i], str, (o + 1));
- if (p > 0) then
- begin
- Result[r] := p;
- o := p;
- Inc(r);
- end;
- until (p <= 0);
- o := 0;
- end;
- SetLength(Result, r);
- SortTIA(Result);
- end;
- procedure FixText(var text: string);
- var
- TIA: TIntArray;
- h, i, o: Integer;
- begin
- TIA := StrPosAllTCA(['I', 'l'], text);
- h := High(TIA);
- if (h < 0) then
- Exit;
- for i := 0 to h do
- begin
- if (TIA[i] > 1) then
- o := Ord(text[(TIA[i] - 1)]);
- case text[TIA[i]] of
- 'I': if (TIA[i] > 1) then
- if (InRange(o, 65, 90) or InRange(o, 97, 122) or (o = Ord(' '))) then
- text[TIA[i]] := 'l';
- 'l': if (TIA[i] = 1) then
- text[TIA[i]] := 'I'
- else
- if not (InRange(o, 65, 90) or InRange(o, 97, 122)) and (o <> Ord(' ')) then
- text[TIA[i]] := 'I';
- end;
- end;
- SetLength(TIA, 0);
- end;
- var
- str: string;
- begin
- ClearDebug;
- str := 'lol, JaniIabo is a noooob, Iets test this out.. ShouId we?';
- WriteLn('Before FIX: ' + str);
- FixText(str);
- WriteLn('After FIX: ' + str);
- end.
Advertisement
Add Comment
Please, Sign In to add comment