...

/

Regular Expressions

Regular Expressions

Learn how to use regular expressions to describe regular languages.

Regular expressions are a convenient notation for representing strings that match simple text patterns. The expression aacba^*ac^*b^* 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

  1. These are regular expressions:

    a) ϕ\phi, representing the empty language/set, {}\{ \}

    b) λ\lambda, representing the one-string language/set, {λ}\{\lambda\}

    c) cc, for each character, cc in the alphabet Σ\Sigma, representing the language/set {c}\{c\}

  2. For regular expressions r,r1,r2r, r_1, r_2, the following are also regular expressions:

    a) r1+r2r_1 + r_2 (union)

    b) r1r2r_1r_2 ...

Access this course and 1400+ top-rated courses and projects.