NAME:
STRREPL (function)
PURPOSE:
replace one (or more) character(s)/string(s) in a string
CATEGORY:
string routines
CALLING SEQUENCE:
Result = STRREPL(str, index, rchar)
INPUTS:
STR -> the string to be changed
INDEX -> position of the character(s) to be replaced or a
string to be changed in STR.
RCHAR -> replacement character/string
KEYWORD PARAMETERS: none
OUTPUTS:
another string
SUBROUTINES:
REQUIREMENTS:
NOTES:
Known shortcoming: if index is an array, it must contain all
valid elements (only the first entry is checked).
EXAMPLE:
; Convert one letter into upper case
abc = 'abcdefghijklmnopqrstuvwxyz'
print,strrepl(abc,strpos(abc,'m'),'M')
; prints "abcdefghijklMnopqrstuvwxyz"
; Use with strwhere function
a = 'abcabcabc'
print,strrepl(a,strwhere(a,'a'),'#')
; prints "#bc#bc#bc#bc#bc"
IDL> print, strrepl(a,'bc','!eeee!')
a!eeee!a!eeee!a!eeee!
IDL> print, strrepl(a,'b','0000')
a0000ca0000ca0000
IDL> print, strrepl(a,'toto','0000')
abcabcabc
MODIFICATION HISTORY:
mgs, 02 Jun 1998: VERSION 1.00