Click to Rate and Give Feedback
Collapse All/Expand All Collapse All
This page is specific to
.NET Framework 3.0

Other versions are also available for the following:
JScript
substr Method (Windows Scripting - JScript)

Returns a substring beginning at a specified location and having a specified length.

stringvar.substr(start [, length ]) 
stringvar

Required. A string literal or String object from which the substring is extracted.

start

Required. The starting position of the desired substring. The index of the first character in the string is zero.

length

Optional. The number of characters to include in the returned substring.

If length is zero or negative, an empty string is returned. If not specified, the substring continues to the end of stringvar.

The following example illustrates the use of the substr method.

function SubstrDemo(){
   var s = "The quick brown fox jumped over the lazy dog.";
// Get substring.
   var ss = s.substr(10, 5);  
// Returns "brown".
   return(ss);                
}
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker