An exercise in parsing regular expressions