REPLACE: Replacing a String

How to:

REPLACE replaces all instances of a search string in an input string with the given replacement string. The output is always variable length alphanumeric with a length determined by the input parameters.

Syntax: How to Replace all Instances of a String

REPLACE(input_string , search_string , replacement)

where:

input_string

Alphanumeric or text (An, AnV, TX)

Is the input string.

search_string

Alphanumeric or text (An, AnV, TX)

Is the string to search for within the input string.

replacement

Alphanumeric or text (An, AnV, TX)

Is the replacement string to be substituted for the search string. It can be a null string ('').

Example: Replacing a String

REPLACE replaces the string 'South' in the Country Name with the string 'S.'

REPLACE(COUNTRY_NAME, 'SOUTH', 'S.');

For South Africa, the result is S. Africa.

Example: Replacing All Instances of a String

REPLACE removes the characters 'DAY' from the string DAY1:

REPLACE(DAY1, 'DAY', '' )

For 'SUNDAY MONDAY TUESDAY', the result is 'SUN MON TUES'.

WebFOCUS

Feedback