pub fn replch(instr: &str, old: char, new: char, outstr: &mut str)Expand description
Replace characters in a string
Replace all occurrences of a single character with a second character.
§Brief I/O
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
INSTR I Input string.
OLD I Character to be replaced.
NEW I Replacement character.
OUTSTR O Output string.§Detailed Input
INSTR is the input character string, possibly containing
one or more occurrences of the character OLD.
OLD is the character to be replaced wherever it occurs in
the input string.
NEW is the character which is to replace each occurrence
of the character OLD in the output string.§Detailed Output
OUTSTR is the output string. This is the input string
with every occurrence of the character OLD replaced
by the character NEW.
OUTSTR may overwrite INSTR.§Exceptions
Error free.§Particulars
Copy the contents of the input string to the output string
a character at a time, replacing each occurrence of OLD with NEW.
If the output string is not long enough to contain the input
string, it is truncated on the right.§Examples
Let
INSTR = 'Woodsy is the Anti-Pollution Owl.'
OLD = 'O'
NEW = 'E'
then
OUTSTR = 'Woodsy is the Anti-Pollution Ewl.'
Note the case-sensitivity of REPLCH. The lowercase o's are
not affected.
REPLCH may similarly be used to replace control characters
(such as tab stops, line feeds, and nulls) with regular ASCII
characters (such as blanks).§Restrictions
1) REPLCH is sensitive to case, as shown in the examples above.§Author and Institution
J. Diaz del Rio (ODC Space)
W.L. Taber (JPL)
I.M. Underwood (JPL)§Version
- SPICELIB Version 1.1.0, 12-AUG-2021 (JDR)
Added IMPLICIT NONE statement.
Edited the header to comply with NAIF standard.
- SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)
Comment section for permuted index source lines was added
following the header.
- SPICELIB Version 1.0.0, 31-JAN-1990 (WLT) (IMU)