|
|
||||||||||||
SubstringsQuestion: How do I extract a substring from a string?
Answer:
To extract a substring from a string, use the string.substring(start,end)Here string
is the string from which you want to extract a substring.
start
is the number specifying the position of the character at which the substring begins.
(The character at start itself
will be included in the substring.)
end
is the number specifying the position of the character at which the substring ends.
(The character at end
will not be included in the substring.)
Note that the first character in the string corresponds to position 0,
and the last character to position Examples: 'Hello'.substring(0,2) // 'He' 'Hello'.substring(0,4) // 'Hell'
JavaScripter.net.
Copyright
© 1999-2006, Alexei Kourbatov
|
||||||||||||