Creating regex using automata
Keyword: GNFA.
You can use automata diagrams to make creating regex easier.
- states with transitions labelled by regex
- some states accept regex, some reject
- if multiple final states, create new final state, with epsilon (free) transitions from old final states
- if multiple arrows from initial state, create new initial state with epsilon transition to old initial state
- rip out states by combining arrow labels using union (or), until you only have first and last states left
Example: I want to match unclosed input elements, like <input type="checkbox">
Diagrams showing how to build it: