Much much simpler solution using regex capture.