A quantum algorithm for string matching