REU: Shape Recognition as Generalized String Matching