[AIT logo]

Institut für Astronomie und Astrophysik

Abteilung Astronomie

Sand 1, D-72076 Tübingen, Germany
[Uni logo]


strepex Source code in strepex.pro

strepex

Name
             strepex
Purpose
             Performs replacements of parts in strings by using
             regular expressions (REPlacement of regular
             EXpressions). Subexpressions may be also
             inserted into the replacement string.
Category
             String processing
Calling Sequence
             newstring = strepex( string, expression, [replacement],
                                 /fold_case, /all)
Input Parameters
             string     -  the string which will be analyzed and whose
                           parts will be replaced in return.
             expression -  A regular expression as being used for the
                           REGEX function. Subexpressions must be
                           given in parentheses.
             replacement - String to replace for matching regular
                           expressions. If it contains "&n" it
                           will be replaced with the n-th
                           subexpression in expression above
                           (starting from 0). "&" may be escaped with
                           "\&", "\" with "\\".
                           If not given replacement will be empty
                           string (deletion of string).
Optional Input Parameters

Keyword Parameters
              fold_case -  Use case-insensitive regular expression
                           matching. But replacement remains case
                           sensitive.
              all      -   Replace all occurrences of expression in
                           given string. Default is to replace only
                           the first occurrence of expression.
Output Parameters
              Returns the input string with a replacement of all
              occurrences of a matching expression by the replacement
              (which in turn may contain replacements of
              subexpressions).
              If no subexpression was found the input string remains
              unaltered.
Optional Output

Side Effects

Restrictions
            Do not use in time critical sections: It involves lot of
            looping on  input and replacement string (but the
            recursion mentioned in earlier versions was replaced to
            allow escaping).
Procedure

Example
             s = "x5*y3+2"
             s1 = strepex(s,"(x|y)([0-9])","&0(&1)",/all)
             -> s1 contains "x(5)*y(3)+2"
Revision History
            $Log: strepex.pro,v $
            Revision 1.5  2004/06/30 07:15:46  goehler
            replace of subexpression expansion (&n -> n-th subexpression) with a more
            elaborated but quirky version which now supports escaping within replacement string.
            Revision 1.4  2004/06/29 07:55:01  goehler
            added: internal noexpand keyword which fastens up the subexpression expansion
            waiver: implementation of escaping using "\" is wrong. must be replaced with something else
            Revision 1.3  2003/04/09 13:03:37  goehler
            updated documentation/fix of example bug
            Revision 1.2  2002/09/10 07:01:51  goehler
            typos/fixed aitlib html style
            Revision 1.1  2002/09/04 14:59:26  goehler
            string function to perform regular expression replacements.

Last modified by pro2html on 2005 January 04 at 16:42 UTC

[Home Page] [Software, Documentation] [IDL Documentation] [Quick Reference] [Feedback]

Jörn Wilms (wilms@astro.uni-tuebingen.de)
Updated automatically