;+
; NAME:
;             STREP
; PURPOSE:
;             insert new characters in string
; CATEGORY:
;             String processing
; CALLING SEQUENCE:
;             output=strep(input,old,new,/all)
; INPUTS:
;             input=any string
;             old=old characters
;             new=new characters
; KEYWORDS:
;             all = replace all characters
; OUTPUTS:
;             output = new string
; PROCEDURE:
;             uses STRMID
; MODIFICATION HISTORY:
;              written DMZ (ARC) August 1993
;-
function strep,input,old,new,all=all
len=strlen(input) & p=strpos(input,old)
tnew=strtrim(new,2)
if p eq -1 then return,input
leno=strlen(old)
lenn=strlen(tnew)
;-- buffer so that new string tailors with old string
if lenn lt leno then begin
 repeat begin
  tnew=tnew+' '
 endrep until strlen(tnew) eq leno
endif
output=strmid(input,0,p)+tnew+strmid(input,p+leno,len-p-leno+1)
if keyword_set(all) then output=strep(output,old,new,/all)
return,output & end