Library

DFA · Regular

Exactly two b’s

Count the b’s and stop counting at two: any a leaves the count alone, and a third b has nowhere to go.

noneonetwoababa
The machine as drawn — 3 states, 5 transitions.Every word up to length 8, one row per length in shortlex order, inked where it is accepted.

The author’s examples, run

bb → acceptbaab → acceptabb → acceptaaaaaaabba → acceptab → rejectaaab → rejectbbb → rejectbaaaaaabba → reject