$translate

Replaces segments of a character string with new text.

Syntax

$translate(source,pattern,replace)

Parameters

source

a character string, or an expression that evaluates to a character string

pattern

a character string, or an expression that evaluates to a character string

replace

a character string, or an expression that evaluates to a character string

Return Value

Character string, consisting of source, with replace substituted for all occurrences of pattern.

Comments

Use $translate to substitute portions of source with replace. If source, pattern, or replace are not of a character data type, they are converted to a character data type before the function is applied.

If source is of data type ALPHA or VARALPHA, searches for pattern are case-insensitive; otherwise, searches for pattern are case-sensitive.

Example

$translate("the slow brown fox","slow","quick")

Evaluates to "the quick brown fox".

% translates Smith to Smythe
list all Employees where LastName = "Smith" \
  format FirstName $translate(LastName,"ith","ythe")

Translates occurrences of Smith to Smythe in the field LastName.

 

Related Topics