Split Variable Assertion

The Split Variable assertion splits a single-value context variable into multiple values, creating a multivalued context variable as a result.
gateway90
The Split Variable assertion splits a single-value context variable into multiple values, creating a multivalued context variable as a result.
Example
:
The input variable "${varIn}" contains the value "one,two,three". After splitting this variable into "${varOut}", you now have a multivalued context variable where:
${varOut[0]} = one
${varOut[1]} = two
${varOut[2]} = three
Example 2
:
If the specified split pattern cannot be found in the source value, then entire source value is simply copied over to the target: input variable "${varIn}" contains the value "one,two,three" but the split pattern is ';':
${varOut} = one,two,three
${varOut[0]} = one,two,three
Note that if you attempt to use ${varOut[1]} and ${varOut[2]} in this case, no values will be returned.  
Example 3
:
The following is an advanced example that shows the power of using a regular expression in the Split Pattern of the Split Variable assertion. In this example, the full XML syntax is omitted for simplicity; a list of node names is the output:
The input variable "
${varIn}
" contains this fragment:
<xml>
<node>entry 1</node> <node>entry 2</node>
</xml>
The Split Pattern is this regular expression: ((\s)*\<.+?\>[\n]*)
After splitting this variable into "
${varOut}
", you now have a multivalued context variable where:
${varOut[0]} = entry 1
${varOut[1]} = entry 2
For more information about using the indexing feature ([0], [1], etc.) in context variables, see "Indexing Options during Interpolation" under Working with Multivalued Context Variables.
To obtain the length/size of the resulting multivalued context variable, use the ".length" suffix. This is described under "Retrieving Number of Values in a Multivalued Variable" under Working with Multivalued Context Variables.
Using the Assertion
  1. Do one of the following:
    • To add the assertion to the Policy Development window, see Add an Assertion.
    • To change the configuration of an existing assertion, proceed to step 2 below.
  2. When adding the assertion, the
    Split Variable Properties
    automatically appear; when modifying the assertion, right-click
    Split variable <
    source
    > into <
    target
    >
    ... in the policy window and select
    Split Variable Properties
    or double-click the assertion in the policy window. The assertion properties are displayed. 
    The '${ }' wrapper is for illustrative purposes only. It is not necessary to use this wrapper in either variable name. If entered, it will be removed after the assertion is saved.
  3. Configure the properties as follows:
    Setting
    Description
    Source Variable
    Enter the context variable containing the source value to be split.
    Target Variable
    Enter the multivalued context variable that will hold the results of the split. If this variable does not already exist, it will be created.
    Split Pattern
    Enter the pattern that will be used to split the source variable. The Split Pattern will be interpreted as either a regular expression or as a string literal depending on the Regular Expression check box. The default is a comma (','), which indicates splits will occur after each comma found in the source variable.
    Note the following:
    • If the Split Pattern results in no matches on the source variable string, then the target variable's value will be the same as the input string. As a result, "${varOut}" and "${varOut[0]}" will be the same.
    • If the
      Regular Expression
      check box is selected and the Split Pattern cannot be parsed, a validator warning is displayed and a WARNING message will be logged when the policy is saved. This may result in the policy failing each time it is run, as this assertion will fail each time it executes.
    Regular Expression
    Select this check box to interpret the Split Pattern as a regular expression. This setting is the default.
    Clear this check box to interpret the Split Pattern as a literal value.
    Ignore Empty Values
    Select this check box to discard all empty values in the resulting variables, regardless of where they occur.
    Clear this check box to discard only trailing empty values. This setting is the default and it preserves the behaviour of this assertion prior to version 6.1.5.
    Example
    :
     Source string = ",,3,,,"
     Split on ","
    Target =
    ${target}
    If "Ignore Empty Values" = SELECTED, the following value is populated into the variable
    ${target}
    :
    ${target} = 3
    If "Ignore Empty Values" = UNSELECTED, the following values are populated into the multivalued variable
    ${target}
    :
    ${target[0]} = <empty>
    ${target[1]} = <empty>
    ${target[2]} =
    3
     
      
  4. Click 
    [OK
    ] when done. If the [
    OK]
     button is not activated, check that the Target Variable is able to accept a value.