Combinatorial algorithms for pattern matching