with Ada.Text_IO; use Ada.Text_IO; package body p_stringy is function stringReplaceWith(sInput:in String; sReplace:in String; sWith:in String) return String is sOutput:String(1..64):=(others=>'#'); i,j,o,r:Integer; begin i:=1; o:=1; while sInput(i)/='#' loop -- Check for a character match j:=1; while sInput(i+j-1)=sReplace(j) and sReplace(j)/='#' loop j:=j+1; end loop; if sReplace(j)='#' then --Match found r:=1; -- Append sWith, the replacement string to the output while sWith(r)/='#' loop sOutput(o):=sWith(r); o:=o+1;r:=r+1; end loop; i:=i+j-1; else --Match not found so copy characters where we were. sOutput(o):=sInput(i); o:=o+1; i:=i+1; end if; end loop; sOutput(o):='#'; return sOutput; end stringReplaceWith; end p_stringy;