Even if I do this only for fun, I can't imagine a faster method to solve this puzzle.
This work seems to be perfect for the regex engine skills.
The final regex is only the concatanation of a lot of small easy pieces...
But OK, I agree: this is not a good idea to show the generated regex ;-)