Replace a substring using regex