You could probably replace these two lines with a single replaceAll(regex) call.