Don't you want to use gsub instead of tr, as it would be cleaner that it's a regexp.