Term of the Day

The Sinclair ZX Spectrum was a considerably popular personal computer during the 1980s. Developed in Britain, it is often credited for popularizing use of the personal computer in Europe. It featured a screen resolution of 256 by 192 colored pixels (unprecedented at the time for a household computer). It was also known for its multifunction rubber...
Read more

IT Business

Pattern Matching

Definition - What does Pattern Matching mean?

Pattern matching in computer science is the checking and locating of specific sequences of data of some pattern among raw data or a sequence of tokens. Unlike pattern recognition, the match has to be exact in the case of pattern matching. Pattern matching is one of the most fundamental and important paradigms in several programming languages. Many applications make use of pattern matching as a major part of their tasks.

Techopedia explains Pattern Matching

Pattern matching, in its classical form, involves the use of one-dimensional string matching. Patterns are either tree structures or sequences. There are different classes of programming languages and machines which make use of pattern matching. In the case of machines, the major classifications include deterministic finite state automata, deterministic pushdown automata, nondeterministic pushdown automata and Turing machines. Regular programming languages make use of regular expressions for pattern matching. Tree patterns are also used in certain programming languages like Haskell as a tool to process data based on the structure. Compared to regular expressions, tree patterns lack simplicity and efficiency.

There are many applications for pattern matching in computer science. High-level language compilers make use of pattern matching in order to parse source files to determine if they are syntactically correct. In programming languages and applications, pattern matching is used in identifying the matching pattern or substituting the matching pattern with another token sequence.