Institut für Astronomie und Astrophysik
Abteilung AstronomieSand 1, D-72076 Tübingen, Germany
Translate all occurences of one substring to another.
new = strtrans(oldstr,from,to,ned)
oldstr -- string on which to operate. in May be an array. from -- substrings to be translated. May be in an array. to -- what strings in from should be in translated to. May be an array.
/HELP -- Set this to print useful message and exit.
new -- Translated string. Array if oldstr is out an array. ned -- number of substitutions performed in out oldstr. Array if oldstr is an array.
- Any of old, from, and to can be arrays. - from and to must have the same number of elements.
inp='Many*bad!chars+in_here' from=['*','!','+','_'] to =[' ',' ',' ',' '] out = strtrans(inp,from,to,ned) Will produce out='Many bad chars in here', and set ned to 4.
$Id: strtrans.pro,v 1.7 2004/06/15 17:25:54 mcraig Exp $ $Log: strtrans.pro,v $ Revision 1.7 2004/06/15 17:25:54 mcraig Fixed bug in regular expression, changed array notation to square brackets Revision 1.6 2004/01/11 01:49:00 mcraig Changed format of one array to newer  style to avoidf conflict with function name in astro library. Revision 1.5 2001/11/23 21:14:35 mcraig Added keywords /EXTRACT, /PRESERVE_NULL, /REGEX to call to strsplit. This comes very close to reproducing the behavior of the obsolete routine str_sep. Revision 1.4 2001/11/21 19:13:23 mcraig Changed str_sep to strsplit. The former is now considered obsolete by RSI. Revision 1.3 1996/06/14 20:00:27 mcraig Updated Copyright info. Revision 1.2 1996/05/09 00:22:17 mcraig Sped up significantly by using str_sep to handle the translation. No longer relies on routines fromother user libraries. Revision 1.1 1996/01/31 18:47:37 mcraig Initial revision
$Name: Rel_2_1_2 $
Copyright (C) 1996 The Regents of the University of California, All Rights Reserved. Written by Matthew W. Craig. See the file COPYRIGHT for restrictions on distrubting this code. This code comes with absolutely NO warranty; see DISCLAIMER for details.
[Home Page] [Software, Documentation] [IDL Documentation] [Quick Reference] [Feedback]