Javascript Reference
Categories: String

javascript String substr( )

@Feb. 23, 2010, 11:14 a.m.
substr( ) Firefox/Netscape/NN 4 IE 4 ECMA n/a  

substr(startPositionIndex [, length])


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. If no other parameter is provided, the extract continues to the end of the main string. The second parameter can specify an integer of the number of characters to be extracted from the main string. In contrast, the substring( ) method's parameters point to the start and end position index values of the main string.

  • A zero-based integer indicating the position within the current string object to start copying characters
  • An optional integer of the number of characters to extract, starting with the character indicated by the startPositionIndex parameter
Returned Value

A string.

Note for negative position:

Begin from end. "abcdefg".substr(-2) = "fg"
IE6 7 8:
Treat as 0. "abcdefg".substr(-2) = substr(0) = "abcdefg"
Use javascript String slice( ) instead.
purchase lipitor for sale <a href="">atorvastatin 20mg brand</a> atorvastatin 40mg ca
Lhpjmb - 4 months
purchase atorvastatin for sale <a href="">buy lipitor no prescription</a> order atorvastatin 20mg pill
Hezeqa - 4 months

Powered by Linode.