Slice
Last updated
Last updated
Slice Slices a string or an array using specified indices. @param from-index Type int (Default value 0) @param to-index Type int. Input can be a string or a list. If neither, it converts input to a string.
This function allows users to selectively pick a sub-string from a string.
Step 1: Create an empty slice_example_1 using AIOps studio as shown in the below screenshot.
Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:
You can copy the below code into your pipeline and execute that in your environment.
##### This pipeline creates an ipaddress list with different IP addresses as string
##### in a dataset.
##### Pipeline uses RDA dm slice select first and second IP addresses and prints
##### the values.
##### In addition, RDA dm filter function is used to print initial list along with
##### sliced values.
@dm:empty
--> @dm:addrow IPV4_Address_List = '10.95.122.15,10.95.122.16,10.95.122.107'
--> @dm:map from = "IPV4_Address_List" & to = "First_IP" & func = 'slice' & toIdx = 12
--> @dm:map from = "IPV4_Address_List" & to = "Second_IP" & func = 'slice' & fromIdx = 13 & toIdx = 25
--> *dm:filter * get IPV4_Address_List, First_IP, Second_IP
Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)
Step 4: Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)
Step 5: RDA uses the dm function slice to pick the selected IP_Address as per the index that was provided in the pipeline. In the first slice logic, default from the index (default 0) is selected whereas, in the second line, explicit indices are provided to select/slice the required IP Address. Once the IP list is sliced for the first IP Address and second IP Address, it is printed to the output (as shown below) Note: In addition to the above dm function, the pipeline also uses a dm filter function to select the output.