StrSub

Extracts a sub-string out of an existing string.

Syntax:

StrSub (string, start, length)

Parameters:

(s) string the string from which the sub-string is to be extracted.

(i) start character position within string where the sub-string starts. The first character of the string is at position 1.

(i) length length of desired sub-string. If you specify a length of zero (0) it will return a null string. If you specify a length of -1 it will extract the rest of the string.

Returns:

(s) sub-string of parameter string or "".

 

This function extracts a sub-string from within a "target" string. Starting at the "start" position, it copies up to "length" characters into the sub-string.

Example:


a = "My dog has fleas"
animal = StrSub(a, 4, 3)
Message("STRSUB", "My animal is a %animal%")
See Also:

StrInsert, StrLen, StrOverlay, StrScan