Regular Expressions
Learn how to use regular expressions to describe regular languages.
We'll cover the following...
Regular expressions are a convenient notation for representing strings that match simple text patterns. The expression illustrates two of the four regular expression operations, namely concatenation (via juxtaposition) and Kleene star. The others appear in the following recursive definition.
Formal definition
-
These are regular expressions:
a) , representing the empty language/set,
b) , representing the one-string language/set,
c) , for each character, in the alphabet , representing the language/set
-
For regular expressions , the following are also regular expressions:
a) (union)
b) (concatenation)
c) (Kleene star)
d) (grouping)
Note: Some authors (and most programming environments) use the notation for union.
Each regular expression represents a language, which is the set of all strings matching its pattern. Formally, we denote the language associated with a regular expression, , as , so , , and for each symbol from the alphabet in use. The following expressions also hold: