Click or drag to resize

string.substring Function

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
string.substring Function

The string.substring function returns a substring (of a given length, optionally starting at a given character position) from a specified string.

Syntax

Alchemy
string.substring(str, idx, len);

Nomenclature

str Required. The string from which to extract the substring from
idx Required. The starting index of the substring to retrieve, see Returns section below
len Optional. The length of the substring to retrieve, see Returns section below

Returns

If len is not specified:

If idx is < 0 then the string.substring function will str with the last |idx| characters omitted.

Otherwise, string.substring will return str with idx characters removed from the start.

If len is specified string.substring will return len characters from str, starting with character idx (using a zero-based string index).

Example

Alchemy
$name = "Telogis GeoBase";
PRINT string.substring($name, -8); /* 'Telogis' - exclude the last 8 chars */
PRINT string.substring($name, 8); /* 'GeoBase' - exclude the first 8 chars */
PRINT string.substring($name, 11, 4); /* 'Base' - four characters starting with "B" */

The above code snippet produces the following output:

Telogis

GeoBase

Base