REPLACING
Syntax
![]()
Command
Mandatory parameter Optional parameter Mandatory keyword Optional keyword |
INSPECT (<Variable>)
REPLACING (<Option>,
<Old value>, <New value> | <Old values array>, <New values array> | <New character>
[, <Condition>, <Value>])
ENDINSPECT
Description
This command replaces character(s) specified in <Old value> or <Old value array> with the character(s) specified in <New value> or <New value array>. Also all characters can be replaced by a single character using the CHARACTERS option. When a BEFORE or AFTER condition is specified the replace will either stop at <Value> or start after <Value>.
Diagram
Returned value type
None
Parameters
Parameter | Description | |
<Variable> | The variable to be inspected | |
<Option> | CHARACTERS | Replaces all the characters in <Variable> with the character specified in <New Character> or when a BEFORE or AFTER condition has be specified all the characters up to the occurrence of <Value> or all the characters after the occurrence of <Value>. |
ALL | Replaces each occurrence of <Old value> or elements of <Old values array> with <New value> or the correspondig element in <New values array>. When a BEFORE or AFTER condition has been specified the replace will either stop at the occurrence of <Value> or start directly after the occurrence of <Value>. |
|
FIRST | Only the first occurrence of <Old value> or an element of <Old values array> will be replaced by <New value> or the corresponding element in <New values array>. When a BEFORE or AFTER condition has been specified the replace will either stop at the occurrence of <Value> or start directly after the occurrence of <Value>. |
|
LEADING | On the condition that the first character matches <Old value> or an element of <Old values array>, each successive occurrence will be replaced with <New value> or the corresponding element of <New values array>. When a BEFORE or AFTER condition has been specified the replace will either stop at the occurrence of <Value> or start directly after the occurrence of <Value>. |
|
TRAILING | On the condition that the last character matches <Old value> or an element of <Old values array>, each successive occurrence counting backwards from the last character will be replaced by <New value> or the corresponding element of <New values array>. I.e. this option does the exact opposite of LEADING. When a BEFORE or AFTER condition has been specified the replace will either stop at the occurrence of <Value> or start directly after the occurrence of <Value>. |
|
<Old value> | Character or string to search for in <Varaible> and to be replaced by <New value>. | |
<New value> | Character or string to replace <Old value> when found in <Variable>. | |
<Old values array> | Array of characters or strings to search for in <Variable> and to be replaced by the corresponding element in <New values array, in the format [ <Old value 1>, <Old value 2>, ... ]. The [] square brackets are mandatory. | |
<New values array> | Array of characters or strings to replace the corresponding element in <Old values array> when found in <Variable>, in the format [ <New value 1>, <New value 2>, ... ]. The [] square brackets are mandatory. | |
<Condition> | BEFORE | Specifies a BEFORE condition. I.e. the replacing will stop at the first occurrence of <Value> in <Variable>. |
AFTER | Specifies an AFTER condition. I.e. the replacing will start directly after the occurrence of <Value> in <Variable> till the end of <Variable>. | |
<Value> | The start/stop character or string to use in the BEFORE or AFTER condition. |
Example
va-inspect := '**AB**CD**EF'
inspect (va-inspect)
replacing (characters, 'X')
replacing (all, 'X', 'Y')
replacing (first, 'X', 'Y', after, 'Z')
replacing (first, [ 'A', 'B' ], [ 'X', 'Y' ], before, 'Z')
replacing (leading, 'X', 'Y')
replacing (leading, [ 'A', 'B' ], [ 'X', 'Y' ])
replacing (trailing, 'X', 'Y')
replacing (all, [ 'X', 'Y' ], [ 'A', 'B' ])
replacing (all, 'XYZ', 'abc')
replacing (all, OldValue[], NewValue[])
endinspect
inspect (va-inspect)
replacing (characters, 'X')
replacing (all, 'X', 'Y')
replacing (first, 'X', 'Y', after, 'Z')
replacing (first, [ 'A', 'B' ], [ 'X', 'Y' ], before, 'Z')
replacing (leading, 'X', 'Y')
replacing (leading, [ 'A', 'B' ], [ 'X', 'Y' ])
replacing (trailing, 'X', 'Y')
replacing (all, [ 'X', 'Y' ], [ 'A', 'B' ])
replacing (all, 'XYZ', 'abc')
replacing (all, OldValue[], NewValue[])
endinspect