STR_SPLIT
Use the STR_SPLIT script function to split a specified String into several partial strings by using a certain Separator. The result is an array that stores the individual strings. To store the result, you define a script array and fill it with values. Use the string data type when you define the array. The result does not include the separator.
Syntax
STR_SPLIT (String, Delimiter)
Parameters
-
STR_SPLINT
Splits a string into several parts by using a separator -
String
The string that should be split
Format: script literal or script variable -
Separator
Use any character of you choice for this parameter
Format:AE name, script literal or script variable
Return code
Array that includes the individual partial strings
More Information:
Examples
The following example splits the string "123_456_789" as specified with the separator "_" and stores the result in a string array. The individual array elements are then written to the activation report.
:DEFINE &STRINGS#, string, 5
:SET &STRING# = "123_456_789"
:FILL &STRINGS#[] = STR_SPLIT(&STRING#,"_")
:SET &VAR# = 1
:SET &LEN# = LENGTH(&STRINGS#[])
:WHILE &VAR# LE &LEN#
:SET &VAR# = FORMAT(&VAR#,"0")
:PRINT "&VAR#. Partial string = &STRINGS#[&VAR#]"
:SET &VAR# = &VAR#+ 1
:ENDWHILE
Output in the activation report:
2021-10-22 10:30:48 - U0020408 1. Partial string = 123
2021-10-22 10:30:48 - U0020408 2. Partial string = 456
2021-10-22 10:30:48 - U0020408 3. Partial string = 789
2021-10-22 10:30:48 - U0020408 4. Partial string =
2021-10-22 10:30:48 - U0020408 5. Partial string =
See also: