STRREP: Replacing Character Strings

How to:

Reference:

The STRREP replaces all instances of a specified string within a source string. It also supports replacement by null strings.


Top of page

x
Syntax: How to Replace Character Strings
STRREP (inlength, instring, searchlength, searchstring, replength, repstring, outlength, output)

where:

inlength

Numeric

Is the number of characters in the source string.

instring

Alphanumeric

Is the source string.

searchlength

Numeric

Is the number of characters in the (shorter length) string to be replaced.

searchstring

Alphanumeric

Is the character string to be replaced.

replength

Numeric

Is the number of characters in the replacement string. Must be zero (0) or greater.

repstring

Alphanumeric

Is the replacement string (alphanumeric). Ignored if replength is zero (0).

outlength

Numeric

Is the number of characters in the resulting output string. Must be 1 or greater.

output

Alphanumeric


Top of page

x
Reference: Usage Notes for STRREP Function

The maximum string length is 4095.



Example: Replacing Commas and Dollar Signs

STRREP finds and replaces commas and then dollar signs and stores the result in field with the format A17:

STRREP(15,CS_ALPHA,1,',',0,'X',14,'A14')
STRREP(14,CS_NOCOMMAS,1,'$',4,'USD ',17,'A17')

For $29,700.00, the result is USD 29700.00.

For $9,000.00, the result is USD 9000.00.


iWay Software