Progress
Language Reference


REPLACE Function

Interfaces
OS
SpeedScript
All
All
Yes

Returns a string with specified substring replacements.

SYNTAX

REPLACE ( source-string , from-string , to-string ) 

source-string

Specifies the base string to make replacements in. The source-string parameter can be any expression that evaluates to a string. The REPLACE function does not change the value of source-string itself; the function returns the string with replacements.

from-string

Specifies the substring to replace. The from-string parameter can be any expression that evaluates to a string. Each occurrence of from-string within source-string is replaced.

to-string

Specifies the replacement substring. The to-string parameter can be any expression that evaluates to a string. Each occurrence of from-string in source-string is replaced by to-string.

EXAMPLE

The following example uses the REPLACE function to replace the string “user” with an actual user ID, if available.

r-repl.p
DEFINE VARIABLE greeting AS CHARACTER FORMAT "x(40)"
      INITIAL "Starting user’s session . . . ".
IF USERID("DICTDB") < > ""
THEN greeting = REPLACE(greeting, "user", USERID("DICTDB")).

DISPLAY greeting WITH NO-LABELS. 

NOTES

SEE ALSO

OVERLAY Statement, SUBSTITUTE Function, SUBSTRING Function


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095