Abstract
Pattern matching is a basic operation for string processing. Given two strings, we want to find out whether one of them is a substring of the other one. We start in section 10.1 with a simple example. Then in section 10.2 we explain what kind of difficulties we encounter if the pattern contains repetitions. After some preparations in section 10.3 (simple lemmas about prefixes and suffixes) we consider a classical linear time algorithm for pattern matching called the Knuth–Morris–Pratt algorithm (section 10.4). Some other well-known algorithms are considered in the next two sections: in section 10.5 we consider a simplified version of the Boyer–Moore algorithm that can be very efficient for large alphabets. In section 10.6 we consider the Rabin–Karp randomized algorithm. In section 10.7 we discuss an important notion of finite automaton (cf. chapter 5) in its full generality and establish its connection with regular expressions. Finally, in section 10.8 we consider a linear-time pattern matching algorithm that first processes a string and then gets the pattern that should be found in that string.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
Copyright information
© 2010 Springer Science+Business Media, LLC
About this chapter
Cite this chapter
Shen, A. (2010). Pattern matching. In: Algorithms and Programming. Springer Undergraduate Texts in Mathematics and Technology. Springer, New York, NY. https://doi.org/10.1007/978-1-4419-1748-5_10
Download citation
DOI: https://doi.org/10.1007/978-1-4419-1748-5_10
Published:
Publisher Name: Springer, New York, NY
Print ISBN: 978-1-4419-1747-8
Online ISBN: 978-1-4419-1748-5
eBook Packages: Mathematics and StatisticsMathematics and Statistics (R0)