contents   index   previous   next



String substring()

syntax:

string.substring(start, end)

where:

start - integer specifying the position within the string to begin the desired substring.

 

end - integer specifying the position within the string to end the desired substring.

 

return:

string - a substring starting at position start and going to but not including position end.

 

description:

This method retrieves a section of a string. The start parameter is the index or position of the first character to include. The end parameter marks the end of the string. The end position is the index or position after the last character to be included. The length of the substring retrieved is defined by end minus start. Another way to think about the start and end positions is that end equals start plus the length of the substring desired.

 

see:

String charAt(), String indexOf(), String lastIndexOf(), String slice(), String substr()

 

example:

// For example, to get the first nine characters

// in string, use a Start position

// of 0 and add 9 to it, that is,

// "0 + 9", to get the End position

// which is 9. The following fragment illustrates.

 

var str = "0123456789";

str.substring(0, 5)   // == "01234"

str.substring(2, 5)   // == "234"

str.substring(0, 10)  // == "0123456789"

 


String toLocaleLowerCase()