I'm trying to format a mobile number in swift. The number is "+41791234567" and I want it to be like this "+41 79 123 45 67". I tried something like this but I do not know if is correct and I also don't know what is the regular expression for this. If anyone can help, thanks !
public func formatPhoneNumber() -> String {
return self.replacingOccurrences(of: "(\\d{2})(\\d{2})(\\d{3})(\\d{2})(\\d+)", with: "$1 $2 $3 $4 $5", options: .regularExpression, range: nil)
}