function strReplaceOnce(s_txt, s_from, s_to :string): string; var i_pos, len_from:integer; begin i_pos := pos(s_from, s_txt); // Номер символа первого вхождения len_from := Length(s_from); // Длинна строки для замены if (i_pos > 0) and (len_from > 0) then begin delete(s_txt, i_pos, len_from); // Удаляет строку insert(s_to, s_txt, i_pos); // Вставляет нужную строку end; strReplaceOnce := s_txt; // Возвращает результат после всех действий end; function strReplaceAll(s_txt, s_from, s_to :string): string; begin while (pos(s_from, s_txt) > 0) do begin s_txt := strReplaceOnce(s_txt, s_from, s_to); end; strReplaceAll := s_txt; end; begin writeln(strReplaceOnce ('2-3 0123456789-23-23', '23', 'aaaB')); // 2-3 01aaaB456789-23-23 writeln(strReplaceAll ('2-3 0123456789-23-23', '23', 'aaaB')); // 2-3 01aaaB456789-aaaB-aaaB end.