Concept
How can you compute a substring of a string?
ComputerScienceOne / Arrays of Strings
"There are two methods that allow you to compute a substring of a string. The first allows you to specify a beginning index with the entire remainder of the string being included in the returned string. The second allows you to specify a beginning index as well as an ending index. In both cases, the beginning index is inclusive (that is the resulting string includes the character at that index), but in the second, the ending index is exclusive (the character at the end index is not included).\n\nString name = \"Thomas Alan Waits\";\n\nString firstName = name.substring(0, 6); //\"Thomas\"\n\nString middleName = name.substring(7, 11); //\"Alan\"\n\nString lastName = name.substring(12); //\"Waits\"\n\nThe result of the two argument substring() method will always have length equal to endIndex - beginIndex."
Related Ideas
- How can you extract substrings from a string in PHP?ComputerScienceOne · Arrays of Strings
- How can you compute a substring in PHP?ComputerScienceOne · String Functions
- How can you extract substrings from a string in PHP?ComputerScienceOne · Comparisons
- How do you find the length of a string and iterate over its characters?ComputerScienceOne · String Methods
- How do you access individual characters with the String charAt() method?ComputerScienceOne · String Methods
- How can you determine the length of a PHP string?ComputerScienceOne · String Functions
- How does Java make working with strings easier?ComputerScienceOne · Basics
- What are PHP strings and how should they be treated?ComputerScienceOne · Basics