Regular expressions

Regex ⇄ NFA · Chapter 1.3

Regular expressions and finite automata

A language is regular exactly when a regular expression describes it, and exactly when a finite automaton recognizes it. This page lets you move between the two the way Sipser does in Chapter 1.3: build an NFA from any regular expression, piece by piece, and turn any NFA into a regular expression by removing states from a generalized NFA.

Writing expressions

TypeMeans
a|b or a∪ba or b (union)
aba followed by b
a*zero or more a's
a+union or “one or more”, your choice in the panel
ε, \epsilon or ()the empty string
∅ or \emptysetthe empty language
Σ or \Sigmaany one symbol of the alphabet

Regex → NFA

  1. Type an expression, for example (a|b)*abb.
  2. Press Step by step. Each small piece gets its own NFA, and the pieces join with ε-moves for union, concatenation and star.
  3. Use the Convert tab to turn the NFA into a DFA.

NFA → regex

  1. Draw an NFA or DFA, or open one from the finite automata page.
  2. Press Step by step under “Drawing → regex”. A new start and accept state are added, then states are removed one at a time.
  3. Each removal shows the rule R₁R₂*R₃ ∪ R₄ with the real labels.