Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function replaceAll(haystack: string; needle:string; cod:string):string;
- begin
- var s:string = haystack;
- var proc:string = '';
- var p,len:integer;
- len:=length(needle);
- while(length(s)>0) do begin
- p:=s.IndexOf(needle);
- if (p=0) then begin proc+=s; break; end;
- if (p>1) then proc+=copy(s,1,p-1);
- proc+=cod;
- if (p+len)>length(s) then
- s:='' else
- s:=copy(s,p+len,length(s)-p-len);
- end;
- replaceAll:=proc;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement