Funkcia nahradi v InputString vybranu mnozinu znakov z InputStringChar za znaky v OutputStringChar.
function ReplaceSpecialChar(InputString, InputStringChar,
OutputStringChar: string): string;
var
oi: integer;
begin
for oi := 1 to Length(InputStringChar) do
InputString := StringReplace(InputString,InputStringChar[oi],
OutputStringChar[oi],[rfReplaceAll]);
Result := InputString;
end;
Polopate na priklade:
V texte: "Išli sme do lesa až sa zotmelo." chceme nahradit znaky s diakritikou za znaky bez diakritiky.
var InStr, OutStr: String; begin ..... InStr := 'áäčďéěíľňóôřŕšťúůýžÁÄČĎÉĚÍĽŇÓÔŘŔŠŤÚŮÝŽ'; OutStr := 'aacdeeilnoorrstuuyzAACDEEILNOORRSTUUYZ'; MyText := 'Išli sme do lesa až sa zotmelo.'; Caption := ReplaceSpecialChar(MyText, InStr, OutStr); ..... end; |
Komentáre