• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 10. Controlling Text > The String Class

The String Class

You can apply the methods and properties of the String class to analyze and manipulate string data types. The String class can tell you the position of a certain character, for example, or what character occupies a certain position. You can also dissect just a portion of the string and put that part, called a substring, into a new string, or you can concatenate substrings and strings. You can even change the lowercase and uppercase styles of different parts of the string. Table 10.6 summarizes several methods and properties of the String class.

Table 10.6. Methods and Properties of the String Class
METHOD OR PROPERTYDESCRIPTION
indexOf(searchString, fromIndex)Searches the string and returns the index of the first occurrence of a substring specified in the parameter searchString. The optional fromIndex parameter sets the starting position of the search.
lastIndexOf(searchString, fromIndex)Searches the string and returns the index of the last occurrence of a substring specified in the parameter searchString. The optional fromIndex parameter sets the starting position of the search.
charAt(index)Returns the character at the specified index position.
substring(indexA, indexB)Returns the string between the indexA and indexB parameters.
substr(start, length)Returns the string with the specified length from the start index.
concat(string1,...,stringN)Concatenates the specified strings.
toLowerCase()Returns a string that contains all lowercase characters.
toUpperCase()Returns a string that contains all uppercase characters.
lengthA property that returns the length of the string.



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint