Javascript Reference
Categories: String

javascript String substring( )

@July 12, 2008, 5 a.m.
substring( ) Firefox/Netscape/NN 2 IE 3 ECMA 1  

substring(startPositionIndex, endPositionIndex)

  

Returns a copy of an extract from the current string. The extract begins at the zero-based index position of the current string as specified by the first parameter of the method and ends just before the character whose index is specified by the second parameter. For example, "Frobnitz".substring(0,4) returns the substring from positions 0 through 3: Frob. In contrast, the substr( ) method's parameters point to the start position of the main string and the number of characters (length) to extract.

 
Parameters
 
  • A zero-based integer indicating the position within the current string object to start copying characters.
  • A zero-based integer indicating the position within the current string object to end copying characters. In other words, the copy is made from startPositionIndex up to, but not including, the character at position endPositionIndex.
 
Returned Value

A string.


Powered by Linode.