Remove the unwanted charaters in a phone Number iOS swift
Solution:
You can get the phone number from the user in textfield and format it as a valid phone number using the below expression.
The above expression will truncate the special characters in the phone Number.So you can save the phone number directly to your database.
You can get the phone number from the user in textfield and format it as a valid phone number using the below expression.
let ValidNo = number.value.stringValue.replacingOccurrences(of: "[^0-9+]", with: "", options: NSString.CompareOptions.regularExpression, range:nil)
The above expression will truncate the special characters in the phone Number.So you can save the phone number directly to your database.
Comments
Post a Comment