idlastro / Miscellaneous (Non-Astronomy) Procedures: REPSTR

[Source code]

NAME
REPSTR
PURPOSE
Replace all occurences of one substring by another.
EXPLANATION
Meant to emulate the string substitution capabilities of text editors
Obsolete since introduction of the REPLACE method for string variables 
introduced in IDL 8.4
     For a more sophisticated routine that allows regular expressions look
     at MG_STRREPLACE() http://docs.idldev.com/idllib/strings/mg_streplace.html
CALLING SEQUENCE
result = repstr( obj, in, out )
INPUT PARAMETERS
obj    = object string for editing, scalar or array
     in     = substring of 'obj' to be replaced, scalar 
OPTIONAL INPUT PARMETER
out    = what 'in' is replaced with, scalar.   If not supplied
        then out = '', i.e. 'in' is not replaced by anything. 
OUTPUT PARAMETERS
Result returned as function value.  Input object string
not changed unless assignment done in calling program.
PROCEDURE
Searches for 'in', splits 'obj' into 3 pieces, reassembles
with 'out' in place of 'in'.  Repeats until all cases done.
EXAMPLE
If a = 'I am what I am' then print,repstr(a,'am','was')
will give 'I was what I was'.
MODIFICATION HISTORY
Written by Robert S. Hill, ST Systems Corp., 12 April 1989.
Accept vector object strings, W. Landsman   HSTX,   April, 1996
rt loop to LONG, vectorize STRLEN call W. Landsman June 2002
ct bug in optimization, case where STRLEN(OBJ) EQ
 STRLEN(IN), C. Markwardt, Jan 2003
 problem when multiple replacements extend the string length
         D. Finkbeiner, W. Landsman  April 2003
 third parameter to be optional again W. Landsman  August 2003
e limitation of 9999 characters, C. Markwardt Dec 2003
for empty "in" string (causing infinite loop) W. Landsman Jan 2010
mline code W Landsman Dec 2011
tring .replace method in IDL 8.4 or later  W. Landsman Feb 2015