fixed regex for optional trailing space