linerecordsplit

The linerecordsplit command is used to break up a long string into its component parts based on the parameters you define. You can specify the parts by using the 'label' and 'length' option pair described below. This command is available in WS builds of 1.2.194.0 and above. The syntax is as follows.

var elementArr = linerecordsplit(z_string, [{"label":"NUMBERS", "length":10}, {"label":"ALPHABETS", "length":20}]);
Note: The split will always start from the frist character of the string. You cannot extract a portion of the original string from the middle.

Options

The 'linerecordsplit' command takes the following options.

Label

The label is always paired with a length. Together, they identify the parts that you will split the string into a well as the length of the component part that you will create when you split the string. You can either use a single entry format or an array. The two possible synatax options are shown below.

Single Entry
{"label":"NAME1", "length":20}
Array
[{"label":"NAME1", "length":20}, {"label":"NAME2", "length":10}]
Length

The length is always paired with a label. As such, they identify the parts that you will split the string into a well as the length of the component part that you will create when you split the string. You can either use a single entry format or an array. The two possible synatax options are shown below.

Single Entry
{"label":"NAME1", "length":20}
Array
[{"label":"NAME1", "length":20}, {"label":"NAME2", "length":10}]

Example

In the following example, we will split a string into its component parts using the 'linerecordsplit' command.

  1. Create a string variable as shown below.

    var z_string="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  2. Invoke the 'linerecordsplit' command by inputting the following code.

    var elementArr = linerecordsplit(z_string, [{"label":"NUMBERS", "length":10}, {"label":"ALPHABETS", "length":20}]);
  3. In your script, print out the new components of the orginal string as follows.

    println(elementArr.NUMBERS);
    println(elementArr.ALPHABETS);
  4. The results shoudl be as follows:

    • The result for 'elementArr.NUMBERS' should equal: "0123456789"
    • The result for 'elementArr.ALPHABET' should equal: "ABCDEFGHIJKLMNOPQRST"