ScriptEigener Objekttyp in der Automation Engine Function: Replaces characters or strings within a string
Syntax
STR_SUB[STITUTE] (String, [Old], [New])
Syntax |
Description/Format |
---|---|
String |
Alphanumeric string in which the replacement should be carried out |
Old |
Alphanumeric string to be replaced in the string. |
New |
Alphanumeric string to replace Old |
Return code |
---|
String that has been created through the replacement of characters |
Comments
This script function replaces a character or string within a string.
Old and New are optional and not limited. If Old
is not specified as a parameter, each individual empty space is replaced
by the New character or string.
If New is not specified as a
parameter, Old is replaced by
an individual empty space.
If Old is not included in the
string, this function returns the string.
This script function can also be used to delete Old from the string. For this, New must be specified with two successive quotation marks (without empty spaces).
Example
The first example demonstrates how you replace the character "A" with character "B". The result "BBBBB" is output in the activation protocol.
:SET &RET# = STR_SUBSTITUTE ("AAAAA", "A", "B")
:PRINT &RET#
The second example demonstrates how the string "AAAAA" is replaced by character "B". The result "B" is output in the activation protocol.
:SET &RET# = STR_SUBSTITUTE ("AAAAA", "AAAAA", "B")
:PRINT &RET#
The third example demonstrates how the string "AA" is replaced with the string "BB". The result "BBBBA" is output in the activation protocol.
:SET &STR1# = "AA"
:SET &STR2# = "BB"
:SET &RET# = STR_SUB ("AAAAA", &STR1#, &STR2#)
:PRINT &RET#
The fourth example demonstrates how to delete the empty spaces from the string. The result "AE" is output in the activation protocol.
:SET &RET# = STR_SUB ("A E", "
", "")
:PRINT
&RET#
See also:
About Scripts
Script Elements - Alphabetical Listing
Script Elements - Ordered by Function