Exchange Function

Replaces a character in a string.

Syntax

Exchange (string, find.character, replace.character)

string is the string or expression containing the character to replace. A null string returns a null.

find.character is the hexadecimal value of the character to find. If find.character is a null value, Exchange fails and generates a runtime error.

replace.character is the hexadecimal value of the replacement character. If the value of replacement.character is FF, find.character is deleted from the string. If replace.character is a null value, Exchange fails and generates a runtime error.

Remarks

Exchange replaces all occurrences of the specified character.

If NLS is enabled, Exchange uses the first two bytes of find.character and replace.character. Characters are evaluated as follows:
Bytes Evaluated as...
00 through FF 00 through FF
00 through FA Unicode characters 0000 through FA
FB through FE System delimiters

Example

In the following example, 41 is the hexadecimal value for the character "A" and 2E is the hexadecimal value for the period (.) character:

MyString = Exchange("ABABC", "41", "2E")
* result is ".B.BC"
* The above line is functionally equivalent to:
* MyString = Convert("A", ".", "ABABC")