The string, split join trick in Swift

Sometimes you need to split a string by some delimiter and recompose it with another. Or maybe you need to filter a string. It can be done easily like this:

var arr = someString.components(separatedBy: " ")
arr = arr.filter { $0 != "delim"  }
let newString = arr.joined(separator: " ")

//Or for simple delimiter switching there is always the one liner
var newString = someString.components(separatedBy: " ").joined(separator: "_")