[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string manipulation





Craig Markwardt wrote:
> 
> I have been thinking about the following problem, but have been pretty
> frustrated.
> 
> I have input keyword/value strings of the following form.  People may
> recognize this from a FITS file.
> 
> TTYPE2  = 'X1LSpecPcu0'        / X1LSpecPcu0 : Histogram
> TUNIT2  = 'count   '
> 1CTYP2  = 'CHANNEL '
> 1CPIX2  = '0~4,5:53,(54~135;2),(136~237;3),(238~249;4),250~255'
> 12CD2A  = 1.25
> ^name^^   ^value^^^^^^^
> 
> All of the keyword names have a trailing "2" which indicates that they
> are describing column number 2 in a FITS table.  Note that in the name
> "12CD2A", only the *final* 2 refers to the column number.

...


Dear Craig,

I believe my replace_string is the right tool for your request

txt= ['TTYPE2' ,$
      'TUNIT2', $
      '1CTYP2', $
      '1CPIX2' ,$
      '12CD2A']

result=replace_string(txt,'2','50',pos=4,no_of_replaces=1)
print,result
TTYPE50 TUNIT50 1CTYP50 1CPIX50 12CD50A
 
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_html/dbase/download/replace_string.tar.gz

For further routines and licensing please look at
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.html


regards
Reimar


-- 
Reimar Bauer 

Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
=============================================
a IDL library at ForschungsZentrum Jülich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.html

http://www.fz-juelich.de/zb/text/publikation/juel3786.html