Description

The StringSplitIndexGen splits the referenced String based on a delimiter, which in turn creates an internal list. The elements from the list can then be accessed using the list index. 


This tool can be used to parse a string and extract a value at a specified index position. For example, you can use it to: 

  • Extract a portion of a date and timestamp string
  • Retrieve the date or transaction amount from a transaction
  • Extract the birthdate from customer information


In This Article


Generator Parameters

The following parameters may be configured for the StringSplitIndexGen Generator. Items with an asterisk* are required. 

  • value* - Defines a reference to another Attribute or a reference to a Generator in linked Generators. It can also be a constant string. It is the String that the Generator splits based on the delimiter specified by the User.
  • delimiter* - Defines a delimiter that will be used to split the referenced/constant String. It can also accept regular expressions (e.g., for space, use \s character).
  • index* - Defines an integer value that will be used to access an element from the list. This value can also be random, based on the value of another referenced Generator. The index starts from 0. To read the value from last, use a negative index value.
  • ignoreBound* - Defines whether to ignore the out-of-bound exception for the cases where the list's size is less than the index. For example, if the list's size is '4' and an index of '5' is entered with this parameter set to 'true', then empty values will be generated. However, if false, you will receive an error. 



Sample Output


Example 1 - Extract Last Name from Full Name

A tester wants to extract only the last name from each user's full name and use that value to generate their test data. Examples are provided below:



Two Linked Generators are used to provide a simple example: 

  • FullNameGen - generates full name (first, middle initial, and last)
  • StringSplitIndexGen - extracts the last name from the full name


FullNameGen 

  • prcntTitle - 0, no title will be generated
  • prcntSuffix - 0, no suffix will be generated



StringSplitIndexGen

  • value - references the FullNameGen (gen1)
  • delimiter - \s, each value is separated by a space
  • index - 3, it will be split at index position 3 (last name)
  • ignoreBound - true, an empty value will be generated if the index is larger than the list of values




Example 2 - Extract Date Portion of Timestamp

For this example, a tester had a date value that includes both the date and timestamp. They need to extract the date from the string and use it in the generated output. 



This example uses two Linked Generators: 

  • FlexibleDateRangeGen - Generates the date and time stamp values
  • StringSplitIndexGen - Extracts the date from the string



FlexibleDateRangeGen

  • format - the date and timestamp format, MM-dd-yyyy HH:mm:ss



StringSplitIndexGen

  • value - references the FlexibleDateRangeGen (gen1)
  • delimiter - \s, index starts at 0 and increases for each encountered space
  • index - 0, the date value is the first value and is in the zero index position
  • ignoreBoundtrue, an empty value will be generated if the index is larger than the list of values