Altair® Monarch®

 

Function: LSplit

Description

Starts on the left and splits string into maxparts number of parts using sep as the separator (the separator may be a single character or a substring), returning part n.

Syntax

LSplit(string,maxparts,sep,n)

Arguments

string is the string you want to split apart. The string can be a constant, a character field, an expression that results in a string or a function that returns a string.

maxparts represents the maximum number of substrings you want to parse the string into. This value can be a constant, a numeric field, an expression that results in a number or a function that returns a number.

sep is the separator that tells the application where to split the string. The separator may be a single character or a substring.

n tells the application which substring (from the left) you want the function to return. This value can be a constant, a numeric field, an expression that results in a number or a function that returns a number.

Return value

This function returns a character string.

Calculated field example

If the Title field contained the value Bach, Cantatas BWV 56,57,57,152, the following calculated field expression would return Cantatas BWV 56,57,57,152: LSplit(Title,2,",",2)

The first argument (Title) specifies the field to split. The second argument (2) tells the application to split the field into a maximum of 2 substrings. The third argument (",") tells the application where to split the field, in this case on the comma between "Bach" and " Cantatas". The fourth argument (2) tells the application which substring to return, in this case the second substring " Cantatas BWV 56,57,57,152".

Note 1: If we were to specify 3 as the second argument, the application would split the field into three substrings of "Bach", " Cantatas BWV 56" and "57,57,152". This time it would return " Cantatas BWV 56", the second of three substrings.

Note 2: In this example it makes sense to split the field based upon the comma delimiter. You can use any character as the delimiter, but be careful, the application does not include the delimiter when it breaks out each substring.

Filter/Find example

Records with a Title field value of Bach, Art of Fugue or Bach, Cantatas BWV 56,57,57,152 can be selected or found using the expression: LSplit(Title,2,",",1)="Bach"