String.substring

Returns a subset of a String object.

Method of String

Syntax

substring( indexA, indexB )

Parameters

Parameter Description
indexA An integer between 0 and 1 less than the length of the string that specifies the position of the first character.
indexB An integer between 1 and the length of the string that is one greater than the position of the last character.

Description

substring extracts characters from indexA up to but not including indexB. In particular:

  • If indexA is less than 0, indexA is treated as if it were 0.
  • If indexB is greater than stringName.length, indexB is treated as if it were stringName.length.
  • If indexA equals indexB, substring returns an empty string.
  • If indexB is omitted, indexA extracts characters to the end of the string.

See also

String.substr

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