>  Docs Center  >  Libraries  >  Motley  >  MGH_STR_SUBST
Libraries

MGH_STR_SUBST

MGH_STR_SUBST

Name


  MGH_STR_SUBST

Purpose


  String substitution.

Category


  Strings.

Calling Sequence


  Result = MGH_STR_SUBST(Original, Old, New)

Inputs


  Original: The string to be processed. May be an array.
  Old: Remove this substring ...
  New: ...and replace it with this.

Output Parameters


  This function returns a string (array) with the same shape as the original.

Procedure


  If both Old and New are single characters, arguments are converted to
  BYTE type and the substitution is done using the WHERE function. Otherwise
  a more complicated scan through the original is done. Note that this is
  substantially slower.
  Like most text-editor search & replace commands, the m-character ->
  n-character substitution can leave instances of the 'old' string
  in the output.
      print,MGH_STR_SUBST('aaaaa','aaa','aa')
          aaaa
###########################################################################
  This software is provided subject to the following conditions:
  1. NIWA makes no representations or warranties regarding the
    accuracy of the software, the use to which the software may
    be put or the results to be obtained from the use of the
    software. Accordingly NIWA accepts no liability for any loss
    or damage (whether direct of indirect) incurred by any person
    through the use of or reliance on the software.
  2. NIWA is to be acknowledged as the original author of the
    software where the software is used or presented in any form.
###########################################################################

Modification History


  Mark Hadfield, Oct 1993:
    Written, based on IDL Astronomy Library functions REPCHR and REPSTR,
    and a recursion algorithm from William Thompson.
  Mark Hadfield, Oct 1999:
    For the multiple-character case, removed recursion code. This is handled more
    simply by setting up an output array then stepping through the elements.



© 2024 NV5 Geospatial Solutions, Inc. |  Legal
   Contact Us