$substring

Extracts a segment of a character string.

Syntax

$substring(source,position,length)

Parameters

source

a character string, or an expression that evaluates to a character string

position

a number, or an expression that evaluates to a number

length

a number, or an expression that evaluates to a number

Return Value

Character string, containing a string extracted from source, whose first character is position characters into source, and whose length is length characters.

Comments

Use $substring to extract a portion of source. The resulting string contains length characters, starting position characters into source.

If source is not a character data type, it is converted to a character data type before the function is applied.

If position is beyond the end of source or if length is zero or negative, the result is the null string.

If position+length is longer than source, the result consists of all characters from position to the end of source.

Example

$substring("the quick brown fox jumped",7,5)

Extracts "ick b" from the string.

$substring(9999,1,1)

Evaluates to " " (the number is converted to a string).

$substring(5+4,17,1)

Evaluates to "9" (the number is converted to a string).

 

Related Topics