I'm trying to use the String.replacingOccurrences
to change all occurrences of the following characters into commas:
#.$[]
However I can't seem to get it to accomplish this with what I have:
func cleanStr(str: String) -> String {
return str.replacingOccurrences(of: "[.#$[/]]", with: ",", options: [.regularExpression])
}
print(cleanStr(str: "me[ow@gmai#l.co$m")) // prints "me[ow@gmai,l,co,m\n"
Can anybody help me see what I'm doing wrong?