repstr(X;L)

Returns the given string with substrings replaced based on a given list of string pairs.

Syntax

repstr(X;L)

Input

Argument Type Description
X text The string on which to apply the function

A column name

L text A space- or comma-separated list of pairs of text strings where L has the form: 'old1' 'new1' 'old2' 'new2'...'oldx' 'newx'

Return Value

Returns the text string X with substrings in X replaced based on the string pairs specified in the list L.

If X is N/A, the result is N/A.

Sample Usage

value list repstr(value;list)
'abcdefg' 'bc' 'RS' 'ef' 'xy' 'aRSdxyg'
'banana' 'ana' 'ANA' 'b' '' 'ANAna'

Example

In the "Product Master" table (pub.demo.retail.prod), let's say we wanted to replace the occurrences of "OZ" with "OUNCE" in the itemdesc column. To do this, we could create a computed column and use the repstr(X;L) function, specifying the itemdesc column name for the X parameter and the replacement pair of strings 'OZ' and 'OUNCE' in the list for the L parameter.

<base table="pub.demo.retail.prod"/>
<willbe name="repstr_results" value="repstr(itemdesc;'OZ' 'OUNCE')"/>
<colord cols="itemdesc, repstr_results"/>

In this example, the value of "PEPSI 20 OZ" has been changed to "PEPSI 20 OUNCE".