LSplit (String)




LSplit (String str, Integer maxTokens, String delimiter, Integer returnToken)


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 left. (Note: The integer value, 0, will return the first split chunk)


Splits a string into a maximum ‘maxTokens’ tokens delimited by ‘delimiter’. Returns token at index ‘returnToken’ counting from the left.

Return Type



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 left to right) of the token generating by splitting the string


We have a sample Customers_Marketing dataset with the field CompanyName. In this example, we want to return the first part of each record in the CompanyName field.

We will use the LSplit function and a Variables object to do this. We will map the CompanyName field from our source object to the str input node of the function transformation object. For the other required inputs of the function transformation object, we will use a Variables object.


maxTokens = 2

Note: As we only want to return the first part of the string, splitting the string into two chunks is sufficient for our case

delimiter =

Note: Since the string values in our case are separated using a space, our delimiter value will also be a space. This value can be replaced with other delimiters, for example, “,”, depending on the data format

returnToken = 0

Note: We are using the value 0, as we want to return the first part of the split string

We will write the output to a Delimited Destination File object.

Now, to view the output, we will right-click on the destination object’s header and select Preview Output. You can see that Astera Data Stack has split the string values in the CompanyName field, and returned only the first part of the split string.

Similarly, if we change the returnToken value to “1”, the second chunk from the two will be returned, as shown below:

Last updated

© Copyright 2023, Astera Software