Use regular expressions to replace in one pass