Theory of Computing
THE HYPERTEXTBOOK
Chapter 2. Finite State Automata, Regular Languages, Regular Expressions, and Regular Grammars
Section 1. Finite State Automata

Example

This finite state automaton recognizes the set of all variable names in a particular programming language.  In this case, variable names must start with a letter, can be followed by letters, digits, and the underscore character.  However, a variable name cannot have more than one underscore in a row.  It may also not end with an underscore.