Fix replaceAll regex to handle spaces correctly