util
Class Wildcard

java.lang.Object
  extended by util.Wildcard

public class Wildcard
extends Object

Compilation: javac Wildcard.java In.java Execution: java Wildcard pattern < wordlist.txt Find all lines in wordlist.txt that match the given pattern by simulating a nondeterminstic finite state automaton using an Boolean array states[] which records all states that the NFSA could be in after reading in a certain number of characters. Patterns supported ------------------------------ * any zero or more characters ? any one character c character c Sample execution: % java Wildcard *wa*t**c*d* < wordlist.txt unwatched waistcoated watchdog watched watchword % java Wildcard .a.e*i*o*u*y < wordlist.txt facetiously % java Wildlard ........................ < wordlist.txt formaldehydesulphoxylate pathologicopsychological scientificophilosophical tetraiodophenolphthalein thyroparathyroidectomize Note: not the most efficient algorithm.


Constructor Summary
Wildcard()
           
 
Method Summary
static boolean matches(String pattern, String text)
          Check if pattern string matches text string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Wildcard

public Wildcard()
Method Detail

matches

public static boolean matches(String pattern,
                              String text)
Check if pattern string matches text string. At the beginning of iteration i of main loop old[j] = true if pattern[0..j] matches text[0..i-1] By comparing pattern[j] with text[i], the main loop computes states[j] = true if pattern[0..j] matches text[0..i]