In test security analyses, answer copying, collusion, and the use of a shared brain dump site can be detected by checking similarity between item response strings. The similarity, however, can possibly be contaminated by aberrant data resulted from careless responding or rapid guessing. For example, some test-takers may answer by repeating a pattern (e.g., ABCDABCDABCD or AAAAAAAA). It is crucial for researchers or practitioners to remove these kinds of repeating patterns before conducting any similarity analysis. In this study, a new algorithm for finding repeating patterns is proposed. The application of this algorithm on real and simulated data showed satisfying results; the simulated repeating patterns were identified 100% by the new algorithm with a negligible false positive rate. Although illustrated only in the context of similarity analysis, the proposed algorithm has broad applications: for example, identifying unmotivated test-takers for school intervention or cleaning data before estimating item parameters under an item response theory model.