The regex is already getting out of hand ;) https://gist.github.com/idank/6382427
At some point I wanted to convert it to a DFA because I thought it will give me more control and flexibility and be more maintainable over time. The thing to look out for is not make it too permissive so it starts catching things that aren't really options.