SUBSTR()

Returns a substring from a main string

Syntax

SUBSTR( <cString>, <nStart>, [<nLen>] ) --> cReturn

Arguments

<cString> Character expression to be parsed

<nStart> Start position

<nLen> Number of characters to return

Returns

<cReturn> Substring of evaluation

Description

This functions returns a character string formed from <cString>, starting at the position of <nStart> and continuing on for a lenght of <nLen> characters. If <nLen> is not specified, the value will be all remaining characters from the position of <nStart>.

The value of <nStart> may be negative. If it is, the direction of operation is reversed from a default of left-to-right to right-to-left for the number of characters specified in <nStart>. If the number of characters from <nStart> to the end of the string is less than <nLen> the rest are ignored.
Examples
      ? SUBSTR( 'HELLO HARBOUR' , 7, 4 )      // HARB
      ? SUBSTR( 'HELLO HARBOUR' ,-3, 3 )      // OUR
      ? SUBSTR( 'HELLO HARBOUR' , 7    )      // HARBOUR
Status

Ready

Compliance

This functions is CA-Clipper compatible with the execption that CA-Clipper will generate an error if the passed string is longer than 64Kb, and Harbour on some plataform is not limit by this size.

Platforms

All

Files

Library is rtl

See Also