String Matching
Projects
13.10 |
Write a program which takes two command-line arguments: a pattern and a file to search. The program should print out each line in the file in which the pattern occurs. Hint: Look at the code from the Anagrams constructor (Figure 11-7) to see how to read from a file. |
13.11 |
The string matching problem is more difficult if the pattern may contain wild cards. A wild card is a character that can match any character in the text. For example, the pattern "de?er", with '?' as a wild card, matches both "defer" and "deter". Modify the comments for AbstractStringMatcher to allow the use of the character '?' as a wild card. Modify two of the subclasses to provide this functionality. Explain why this would be difficult for the other subclass. |