Skip to main content

Pattern matching

  • Chapter
  • First Online:
Algorithms and Programming
  • 3859 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 69.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Alexander Shen .

Rights and permissions

Reprints 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

Publish with us

Policies and ethics