Locating Words at Arbitrary Positions
Learn how to locate words at an arbitrary position in a string.
We are going to continue our discussion surrounding lines and words. Since so much of our work and lives revolve around information presented using these two constructs, it makes sense for us to linger on them for a little longer. We created several helper methods that enable us to perform various word and line-related tasks, such as:
- Resolving the line and column numbers of arbitrary positions
- Counting word occurrences
- Splitting strings into words
We will dive right in and work on a collection of new word-related helper methods aimed at helping retrieve information about words located at arbitrary positions within a string.
Consider the simple phrase “Hello, world.” Let’s say that we need to get the word located at position 9, which corresponds to ...