String REPLACE
Syntax
![]()
Command
Mandatory parameter Optional parameter Mandatory keyword Optional keyword |
<Destination> := <Source>.REPLACE (<Search>, <Replace>[, <All>])
Description
Returns a new string in which the all or only the first occurrences of the specified character(s) are replaced with another specified character or string.
Diagram
Returned value type
Realstring
Parameters
Parameter | Description |
<Destination> |
The variable to hold the new text after the replace. |
<Source> |
An alphanumeric variable holding the source text. The value will not be changed by the string replace command. |
<Search> |
The character(s) which will be replaced. |
<Replace> | The character(s) which will replace the character(s) specified in <Search>. |
<All> | An optional Boolean setting. If set to false, only the first occurrence of the search character(s) will be replaced. If set to true, all the occurrences of the search character(s) will be replaced. The default setting is true. |
Remarks
The string replace command is akin to the String.Replace Method in .NET with an additional option to restrict the replace to only the first occurrence.
Example
orgstring := 'Helloween'
resultstring := orgstring.Replace ('e', 'a', false)
// resultstring is now Halloween
resultstring := orgstring.Replace ('e', 'a-a')
// resultstring is now Ha-allowa-aa-an
resultstring := orgstring.Replace ('e', 'a', false)
// resultstring is now Halloween
resultstring := orgstring.Replace ('e', 'a-a')
// resultstring is now Ha-allowa-aa-an