eats leading and middle spaces, handles escape characters