# 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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2Fv01BphaZjShPqpdQyIek%2F0.png?alt=media)

**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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2Fcho920OC8ANOUmQFiHEl%2F1.png?alt=media)

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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FVohG5rEMU7D2ntn5wIft%2F2.png?alt=media)
