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
-
String
The string that should be split.Format: script literal or script variable.
-
Separator
Use any string of you choice for this parameter.Maximum length: 16 characters.
Format: AE name, script literal or script variable.
Return code
Array that includes the individual partial strings. The array must be of type string and with enough length to store all partial strings. If the array size is smaller than the actual result, then the resulting set will be limited to the size of the array.
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: