> For the complete documentation index, see [llms.txt](https://docs.cloudfabrix.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cloudfabrix.io/rda/rda-userguide/rda-aiops-studio/examples-jupyter/data-mapping-cfxdm-dm-functions/slice.md).

# Slice

**Slice**\
Slices a string or an array using specified indices. \
@param from-index Type int (Default value 0) \
&#x20;@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.

### Example 1:&#x20;

Step 1: Create an empty **slice\_example\_1** using AIOps studio as shown in the below screenshot. 

![Empty pipeline](/files/-MeRtHyvq9rgMhGSrxVQ)

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.\
\
\&#xNAN;*`##### 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`*<br>

![Pipeline code added to empty pipeline created](/files/-MeRyck0-VgpaMzcUj4B)

Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)

![Pipeline code is verified using 'Verify' button as shown above.](/files/-MeRz0YdKEp3w6Eh7wWm)

Step 4:  Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)

![Successful execution of pipeline without any errors](/files/-MeRzTvjpocOPhFHR4fK)

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.

![Successful execution of pipeline using dm function 'slice' and prints output ](/files/-MeRzyMt3z4q96_Cqw6D)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.cloudfabrix.io/rda/rda-userguide/rda-aiops-studio/examples-jupyter/data-mapping-cfxdm-dm-functions/slice.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
