Regex Nfa
Build a Thompson NFA and inspect its matching states character by character.
About this tool
Explore how a regular expression becomes a Thompson nondeterministic finite automaton (NFA). Choose an example or enter a pattern and input. Check evaluates the entire input; Step starts or advances the trace, and Reset returns to character zero. An empty input is valid. Pattern and input support actual line breaks. Enter inserts a line break; Ctrl/Meta + Enter checks the input.
A highlighted circle is an active state, the lone arrow marks the start, and a double circle marks the accepting state. Dashed ε arrows consume no character. After each step the active set includes every state reachable through ε arrows. Acceptance requires an accepting state after the entire input, not just a prefix. The marked character is next; muted characters have already been read. The diagram scrolls locally on small screens.
Supported: Unicode literals, ., |, (), *, +, ?, positive classes [abc] and [a-z], \d, \w, \s, escaped punctuation such as \., and \n, \r, \t, \f, \v. Dot excludes line terminators; \d and \w use ASCII digits/word characters, while \s includes JavaScript whitespace. For example, colou?r accepts color and colour. Input is actual text, not an escaped string.
This teaching tool does not support anchors, negative classes, counted/lazy repetitions, lookarounds, flags or backreferences. Limits: 128 pattern characters, 512 input characters and 256 states. Matching tracks reachable states in O(input length × states) time without backtracking. For searching text or captures use Regex Tester. See Russ Cox: Thompson NFA construction and simulation.
Pattern, input and example selection are saved locally, including invalid drafts. Older saved inputs remain readable. Reload and navigation retain the inputs; evaluation starts again on request. Oversized drafts keep the previous saved copy and show a warning. Long class labels widen only the required graph columns; dense graphs scroll locally with keyboard support.