Your `split` and then `join` things would be more readable as a `gsub`