Finding sequences of data that have a particular structure or matching specific criteria or rules. For character pattern defined by a regular expression, use the tag regular-expressions instead.
Pattern matching is about finding sequences of data having a particular structure or matching specific criteria or rules.
The pattern can be defined by enumerating an explicit list of sequences, by defining expected combinations of sub-sequences, or by defining other criteria or rules, which if true characterize a sequence belonging to the pattern. These criteria/rules can also express some tolerances, which makes pattern-matching also suitable for finding similarity.
Pattern matching also relates to the extraction of data embedded in the patterns that are matched. Some programming language use this feature in language construct, sometimes using the term pattern matching as synonym for unification .
Pattern matching applies to any kind of data, such as binary data, DNA, character strings, graphs, etc...
Further reading:
Disambiguation:
- use string-matching for searching strings
- use regular-expressions for pattern matching in strings, if the patterns are defined by a regular expression