STR_SPLIT

Use the STR_SPLIT script function to split a specified string into multiple partial strings using a defined delimiter. The function returns an array containing the individual partial strings, omitting the delimiter itself. To capture the result, you must define and populate a string-type script array.

Syntax

STR_SPLIT (String, Delimiter)

Parameters

Parameter Description Format
String Specifies the string to split. Script literal or script variable
Delimiter Defines the character or string used as the separation boundary (maximum 16 characters). AE name, script literal, or script variable

Return Codes

The function returns an array containing the individual partial strings. Ensure the target array is defined as a string data type and is large enough to accommodate all resulting elements. If the array is smaller than the number of generated partial strings, the system truncates the results to fit the array's capacity.

Examples

The following example splits the string "123_456_789" using the "_" delimiter, stores the resulting partial strings in a string array, and writes the individual array elements 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 =

Related Topics

See also: