Implemented first string matching algoritm.