Regular expressions or regex is a sequence of characters that specify search patterns.
These patterns are commonly used by string-searching algorithms for “find” or “find and replace” operations on strings, and input validation. They are used in search engine search-and-replace dialogs of word processors and text editors, in text processing utilities, and in lexical analysis. Many programming languages provide regex capabilities that are either built-in or via libraries.
Regular expressions also referred to as patterns, specify sets of strings required for specific purposes. The most simplistic way to specify a finite set of strings is to list its elements. However, there are often more concise ways: for example, the set containing the three strings “geschaft”, “geschäft”, and “geschaeft” can be specified by the pattern g
(ä|ae?)ft; it can be said that this pattern matches each of the three strings.
In most formalisms, if there exists at least one regular expression that matches a particular set then there exists an infinite number of other regular expressions that also match it—the specification is not unique. Most formalisms provide standard operations to construct regular expressions.