i am convert paragraph into words it contains many special characters like
\" , \" . `
how to remove this characters in nsstring and get
I'm sure there's a more elegant solution, but for anyone trying to do this in Swift, here's what I did to make sure there were no special characters in my users' phone numbers.
var phone = "+1 (555) 555 - 5555"
var removeChars: NSCharacterSet = NSCharacterSet(charactersInString: "1234567890").invertedSet
var charArray = phone.componentsSeparatedByCharactersInSet(removeChars)
var placeholderString = ""
var formattedPhoneNumber: String = placeholderString.join(charArray).stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceCharacterSet())
The stringByTrimmingCharactersInSet
might not be necessary.