You are here: Functions > SPLIT()

SPLIT()

SPLIT() breaks a character string into segments separated by characters such as spaces or commas and returns a specified segment. Any character or string can be used as the separator.

Function Format

SPLIT(C1,C2,N)

C1 is the source string
C2 is the character (or the character string) used as a separator
N is the segment to be returned.

SPLIT() returns segment N. If N does not exist, SPLIT() returns an empty string.

Note: If the segment number specified is negative, this implies the number of segments from the end of the string. Therefore, SPLIT(string, delimiter, -1) will select last segment in the string, while SPLIT(string, delimiter, -3) will select the third from last segment in the string. As with positive segments, if the absolute value of the negative number is larger than the number of segments you will get an empty string.

The characters between, but not including, two separators make up a segment. When the source string begins with a separator, the segment that follows is treated as segment two. The comparison of the strings is case-sensitive.

Examples

SPLIT("abc,def,ghijkl",",",2) = "def"

SPLIT("abc,def,ghijkl",",",3) = "ghijkl"

SPLIT("abc/*def/*ghijkl","/*",3) = "ghijkl"

SPLIT("Jane Doe"," ",2) = "Doe"

SPLIT("/abc/efg/","/",2) = "abc"

SPLIT("abc,def,,ghi",",",3) = ""

SPLIT("abc,def,,ghi",",",-3) = "def"

SPLIT("C:\Fraud.Data\test.fil",".",-1) = "fil"