> For the complete documentation index, see [llms.txt](https://documentation.astera.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.astera.com/astera-data-stack-v6/functions/string/rsplit-string.md).

# RSplit (String)

| **Name**    | ***RSplit***                                                                                                                                                                                                                                                                                                                                                                                                              |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Syntax      | RSplit (String str, Integer maxTokens, String delimiter, Integer returnToken)                                                                                                                                                                                                                                                                                                                                             |
| Purpose     | To split a string into chunks, specified by an integer value of a ‘maxTokens’ variable, and delimited by a ‘delimiter’ string value. Returns specified token at index ‘returnToken’, counting from the right. (**Note:** The integer value, 0, will return the first split chunk)                                                                                                                                         |
| Description | Splits a string into a maximum ‘maxTokens’ tokens delimited by ‘delimiter’. Returns token at index ‘returnToken’ counting from the right.                                                                                                                                                                                                                                                                                 |
| Return Type | String                                                                                                                                                                                                                                                                                                                                                                                                                    |
| Parameters  | <p>str \[System.String] – The string to be broken into tokens</p><p>maxTokens \[System.Int32] – The maximum number of tokens to split the string into. -1 is taken to unlimited. The number should be greater than the index of the token to be returned</p><p>delimiter \[System.String]</p><p>returnToken \[System.Int32] – The index (Counting from right to left) of the token generating by splitting the string</p> |

![](https://github.com/astera-software/Astera_Data_Stack_v9/blob/main/.gitbook/assets/0%20\(186\).png)

**Example**

In this example, we are passing the required parameters to the function transformation object using a *Variables* object.

Where,

*str*: A-B-C-D-E-F-G-H-I

*maxTokens =* 3

*delimiter =* - (**Note:** Since the string values in our case are separated using “-”, our delimiter value will also be “-”. This value can be replaced with other delimiters, depending on the data format)

*returnToken* = 2 (**Note:** We are using the value 2, as we want to return the third part of the split string, from the right)

![](https://github.com/astera-software/Astera_Data_Stack_v9/blob/main/.gitbook/assets/1%20\(186\).png)

Right-click on the function transformation object and select *Preview Output.* You can see that Astera Data Stack has returned the third part of the split string, counting from the right.

![](https://github.com/astera-software/Astera_Data_Stack_v9/blob/main/.gitbook/assets/2%20\(187\).png)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://documentation.astera.com/astera-data-stack-v6/functions/string/rsplit-string.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
