Regular Expression - GATE Exercise 7