ToBeReviewed/STRING/
strrepl.pro
replace one (or more) character(s)/string(s) in a string
strrepl
String
result = strrepl(str, agument1, rchar)
Return value
another string
Parameters
str
in
required
the string to be changed
agument1
rchar
in
required
replacement character/string
Examples
; 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
Version history
Version
$Id: strrepl.pro 157 2006-08-21 09:01:50Z navarro $
History
mgs, 02 Jun 1998: VERSION 1.00
sebastien Masson (smlod@ipsl.jussieu.fr)
Known issues
Restrictions
Known shortcoming: if index is an array, it must contain all
valid elements (only the first entry is checked).
Produced by IDLdoc 2.0 on Tue Aug 29 14:50:31 2006.