About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: December 2006

URL: http://cxc.harvard.edu/ciao3.4/strreplace.tm.html
Hardcopy (PDF): A4 | Letter
AHELP for CIAO 3.4 strreplace Context: slangrtl

Synopsis

Replace one or more substrings

Syntax

(new, n) = strreplace (a, b, c, max_n)

Description

   String_Type a, b, c, rep;
   Int_Type n, max_n;

The strreplace function may be used to replace one or more occurances of b in a with c. If the integer max_n is positive, then the first max_n occurances of b in a will be replaced. Otherwise, if max_n is negative, then the last abs(max_n) occurances will be replaced.

The function returns the resulting string and an integer indicating how many replacements were made.

Example

The following function illustrates how strreplace may be used to remove all occurances of a specified substring

  define delete_substrings (a, b)
  {
     (a, ) = strreplace (a, b, "", strlen (a));
     return a;
  }
Hardcopy (PDF): A4 | Letter
Last modified: December 2006



The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.