refactor - using regex to replace characters