String.substr

Returns the characters in a string beginning at the specified location through the specified number of characters.

Method of String

Syntax

substr( start[, length] )

Parameters

Parameter Description
start Location at which to begin extracting characters.
length The number of characters to extract

Description

start is a character index. The index of the first character is 0, and the index of the last character is 1 less than the length of the string. substr begins extracting characters at start and collects length number of characters.

  • If start is positive and is the length of the string or longer, substr returns no characters.
  • If start is negative, substr uses it as a character index from the end of the string. If start is negative and abs(start) is larger than the length of the string, substr uses 0 is the start index.
  • If length is 0 or negative, substr returns no characters. If length is omitted, start extracts characters to the end of the string.

See also

String.substring

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.