© Copyright 2023, Astera Software
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 | str [System.String] – The string to be broken into tokens 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 delimiter [System.String] returnToken [System.Int32] – The index (Counting from right to left) of the token generating by splitting the string |
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)
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.