Algorithms on Strings: Pattern matching automata