Regular Expression

A regular expression (often written as regex) is a syntactic description of a Regular Language over an Alphabet .

Regular expressions are built recursively from basic symbols using a small set of operations that correspond to ways of combining languages.

Formally: The class of regular expressions over is defined by:

  1. Base cases:
    • represents the empty language.
    • represents the language containing only the Empty String.
    • For each symbol , represents the language .
  2. Recursive Case
    • If are regular expressions, then:
      • (or ) represents union.
      • represents concatenation.
      • represents the Kleene Star (zero or more repetitions).

The language described by a regular expression is written .

Example

If , then represents all strings over that end in .