Abstract

A string pattern-matching algorithm uses a character string, pattern, to search another character string, text, for the first or all occurrence(s) of the pattern in the text. This article presents a string patternmatching algorithm using a mapping table and an automaton. The number of states of the automaton is equal to the length of the pattern and its number of inputs is one more than the number of different characters in the pattern. During the search, when a mismatch occurs between a pattern character and a text character, the jump to the next position for comparison is made optimal based on the information in the automaton. For non case-sensitive pattern matching, the translation of cases is all done in the mapping table in linear time of the sum of the pattern length and the size of the alphabet; the search part does not do any translation. Experimental results confirm that the ratio of the number of characters inspected over the number of characters passed is better than that of the Boyer-Moore algorithm. The search loop is also very simple and machine independent. Therefore, the algorithm should appeal to anyone who needs a universal search routine that does not depend on statistics of characters.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call