Freigeben über


CHRTRAN( ) Function

Replaces each character in a character expression that matches a character in a second character expression with the corresponding character in a third character expression.

CHRTRAN(cSearchedExpression, cSearchExpression, cReplacementExpression)

Return Values

Character

Parameters

  • cSearchedExpression
    Specifies the expression in which CHRTRAN( ) replaces characters.

  • cSearchExpression
    Specifies the expression containing the characters CHRTRAN( ) looks for in cSearchedExpression.

  • cReplacementExpression
    Specifies the expression containing the replacement characters.

    If a character in cSearchExpression is found in cSearchedExpression, the character in cSearchedExpression is replaced by a character from cReplacementExpression that's in the same position in cReplacementExpression as the respective character in cSearchExpression.

    If cReplacementExpression has fewer characters than cSearchExpression, the additional characters in cSearchExpression are deleted from cSearchedExpression. If cReplacementExpression has more characters than cSearchExpression, the additional characters in cReplacementExpression are ignored.

Remarks

CHRTRAN( ) translates the character expression cSearchedExpression using the translation expressions cSearchExpression and cReplacementExpression and returns the resulting character string.

Example

? CHRTRAN('ABCDEF', 'ACE', 'XYZ')  && Displays XBYDZF
? CHRTRAN('ABCD', 'ABC', 'YZ')  && Displays YZD
? CHRTRAN('ABCDEF', 'ACE', 'XYZQRST')  && Displays XBYDZF

See Also

CHRTRANC( ) | SYS(15) - Character Translation | Creating Character Expressions | STRTRAN( )