REPLACE function
- Last Updated: January 18, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
Returns a string with specified substring replacements. The data type of the returned value matches the data type of the expression passed to the function.
Syntax
|
- source-string
- Specifies the base string to make replacements in. The source-string parameter can be any expression that evaluates
to a string or a LONGCHAR. The
REPLACEfunction 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 or a LONGCHAR. 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 or a LONGCHAR. 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
|
Notes
- The
REPLACEfunction replaces all occurrences of from-string within source-string. After replacing a substring, theREPLACEfunction resumes searching the string after the inserted text. Thus, the inserted text is not recursively searched (in whole or in part) for from-string. - The search for occurrences of from-string within source-string is not case sensitive, unless one of the three values used in the function (source-string, to-string, or from-string) is a case-sensitive field or variable.
- If any of the arguments to the
REPLACEfunction evaluate to the Unknown value (?), the function returns the Unknown value (?).