If you concatenate the strings first, you will only have to call replace() once.