| substr() The substr() method is used to return the charcacters which are in the positions defined by numberOne and numberTwo (see syntax). The characters between the two numbers will be returned. Keep in mind that the values returned are zero based integers. That is, the first character of the string will be number 0 (zero), the next will be one, and so on. If numberOne is a negative number, it will be treated as a 0 (zero). If numberTwo is greater than the length of the string or a string.length setting, it will be treated as the string.length. If numberOne is equal to NumberTwo, an empty string will be returned (NOT null or undefined, simply empty). syntax: string.substr(numberOne, numberTwo) string.substr(number) EXAMPLE var stringToSearch = new String("This is the string text"); var stringToSearch2 = stringToSearch.substr(5,12); document.write("The returned string is : " + stringToSearch2) The example first creates a new string object called stringToSearch. This string is then acted upon with the substr() method, returning the characters starting at position 5 and ending with position 12. The contents of the search are placed in the stringToSearch2 string and written to the screen by a document.write statement. The output should look like the following: The returned string is : is the |