Replace certain characters at the left and right of a string
REPLALL( <cString>, <cReplace|nReplace>, [<cSearch|nSearch>] ) -> cString
<cString> [@] Designates the string that is processed.
<cReplace|nReplace> Designates the character that replaces the character in <cSearch|nSearch> at the beginning and end of <cString>.
<cSearch|nSearch> Designates the character at the beginning and end of <cString> that is replaced by <cReplace|nReplace>. The default value designates a space, CHR(32).
The processed <cString> is returned.
REPLALL() can be used to exchange all leading and trailing spaces in a character string for any other character. Notice that the first non- replaceable character in either direction causes REPLALL() to stop replacing characters on that side.
. The return value of this function can be suppressed by implementing CSETREF() to save space in working memory.
. Replace spaces with dashes. Replace the spaces only on the side where the character was found: ? REPLALL("abcd ", "-") // "abcd--" . Replace zeros with spaces: ? REPLALL("001234", " ", "0") // " 1234" . Replace the blanks with dashes on both sides: ? REPLALL(" d ", "-") // "---d--" . Replace only continuous sequences of characters at the beginning and the end of the character string: ? REPLALL(" d d ", "-") // "-d d--"
REPLALL() is compatible with CT3’s REPLALL().
Source is replace.c, library is libct.
REPLLEFT(), REPLRIGHT(), CSETREF(), Introduction