STRING_SEG macro

The STRING_SEG macro is available only in Unica Campaign.

Syntax

STRING_SEG(from, to, data)

Parameters

from

The number of characters offset from the beginning of the string to start extracting the string segment from. This must be a positive integer greater than zero and less than to, or STRING_SEG returns an empty string.

to

The number of characters offset from the beginning of the string to stop extracting the string segment from. This must be a positive integer greater than or equal to from. If to equals from (and to is less than or equal to the length of the string), one character is returned.

data

ASCII text string values. This can be ASCII text in quotes, a column of text, a cell range containing text, or an expression evaluating to any of the above. For the format definition of data, see the "Macro Function Parameters" section in the chapter in this guide for your product.

Description

STRING_SEG returns the string segment between two indexes from each string value in the specified data range. If from is greater than the length of a string, nothing is returned. If to is greater than the length of a string, all characters from from are returned.

Examples

TEMP = STRING_SEG(1, 6, "JAN 15, 1997")

Creates a new column named TEMP, which contains the ASCII text string " Jan 15 ".

TEMP = STRING_SEG(5, 20, "Pressure")

Creates a new column named TEMP, which contains the ASCII text string " sure ".

TEMP = STRING_SEG(5, 6, V1)

Creates a new column named TEMP containing the fifth and sixth characters of each string in column V1.

TEMP = STRING_SEG(10, 20, V1:V3)

Creates three new columns named TEMP, VX, and VY. The values in the TEMP column are characters 10-20 of the strings in the corresponding rows of column V1, the values of the VX column are the characters 10-20 of strings in corresponding rows of column V2, and the values of the VY column are the characters 10-20 of the strings in corresponding rows of column V3.

TEMP = STRING_SEG(5, 10, V4[1:50]:V6]

Creates three new columns named TEMP, VX, and VY. The values in the TEMP column are characters 5-10 of the strings in rows 1-50 of column V1, the values of the VX column are characters 5-10 of strings in rows 1-50 of column V2, and the values of the VY column are characters 5-10 of the strings in rows 1-50 of column V3.

Related functions

Function Description
STRING_CONCAT Concatenates two text strings from the specified data ranges
STRING_HEAD Returns the first n characters of each string in the specified data range
STRING_LENGTH Returns the length of each string in the specified data range
STRING_TAIL Returns the last n characters of each string in the specified data range