Replace character - Connect_CDC - connect_cdc_mimix_share - 5.8

Connect CDC System Reference Guide

Product type
Software
Portfolio
Integrate
Product family
Connect
Product
Connect > Connect CDC (MIMIX Share)
Version
5.8
Language
English
Product name
Connect CDC
Title
Connect CDC System Reference Guide
Copyright
2024
First publish date
2003
ft:lastEdition
2024-02-12
ft:lastPublication
2024-02-12T15:11:59.486869

Method: Replace character

Function name:   replacechar

Parameter list:   (CHAR input, character searchChars, character replaceChar)

Return type:   CHAR

What the method does:    Copies the input source string to the output string, replacing characters in the source string with the replacement character or stripping out the character if there is no replacement character. 

The searchChars is a list of one of more characters that is searched for and replaced each in turn, one at a time.

If the replacement character is specified as a zero length string, then this is the indication to strip the character out and throw it away as opposed to replacing it.

A zero length string is defined as the literal ' ' or as a character string with no characters defined in it.

The second argument contains a list of characters that are candidates for replacement by the third argument, which is the replacement character.

The string containing the replacement character can contain more than one character, but only the first character is taken as the replacement character.

If the input string is a zero length string and the search string is a zero length string then the replace character is returned.

This is the way that this method can be used to change a zero length string to some other desired string.

A character string used in these methods can support literals that can contain any character that we currently support. So, it is possible to look for and replace a binary zero as specified like '\0'.

Examples:

replacechar('[cTTaaUUaaXXaYYYbbbZZZZab]', 'abc', '_' );   

returns

[_TT__UU__XX_YYY___ZZZZ__]
 
replacechar('[cTTaaUUaaXXaYYYbbbZZZZab]', 'abc', '' );   

returns

[TTUUXXYYYZZZZ]
replacechar('(\0\0\0\0\0BINARY ZEROS: YUCK!\0\0\0\0\0\0)', '\0', '');

returns

(BINARY ZEROS)

Trim could have been used in this case but not if the binary zeros were intermixed in amongst the source characters as in the next example.

replacechar('(HOLLYWOOD\0\0\0\0\0CALIF.)','\0', ' ');   

returns

(HOLLYWOOD     CALIF.)