Quantcast
Channel: How to remove special characters from string in Swift 2? - Stack Overflow
Browsing index pages (8 articles)
↧

Answer by Rodolfo Teixeira for How to remove special characters from string...

without removing spaces between wordsextension String { var removeSpecialCharacters: String { return self.components(separatedBy: CharacterSet.alphanumerics.inverted).filter({ !$0.isEmpty...

View Article


Answer by Ben Lin for How to remove special characters from string in Swift 2?

Try this:someString.removeAll(where: {$0.isPunctuation})

View Article


How to remove special characters from string in Swift 2?

The answer in How to strip special characters out of string? is not working. Here is what I got and it gives me an error func removeSpecialCharsFromString(str: String) -> String { let chars:...

View Article

Answer by Martin R for How to remove special characters from string in Swift 2?

In Swift 1.2, let chars = Set("abcde...") created a set containing all characters from the given string. In Swift 2.0 this has to be done as let chars = Set("abcde...".characters) The reason is that a...

View Article

Answer by matt for How to remove special characters from string in Swift 2?

Like this: func removeSpecialCharsFromString(text: String) -> String { let okayChars : Set<Character> = Set("abcdefghijklmnopqrstuvwxyz...

View Article


Answer by Maksim Kniazev for How to remove special characters from string in...

SWIFT 4: func removeSpecialCharsFromString(text: String) -> String { let okayChars = Set("abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLKMNOPQRSTUVWXYZ1234567890+-=().!_") return text.filter...

View Article

Answer by Bisca for How to remove special characters from string in Swift 2?

I think that a cleaner solution could be this approach: extension String { var alphanumeric: String { return self.components(separatedBy: CharacterSet.alphanumerics.inverted).joined().lowercased() } }

View Article

Answer by Leo Dabus for How to remove special characters from string in Swift 2?

If you need to keep only ascii printable characters in a string you can just filter them checking if their unicodeScalar values are ascii: extension Character { var isAscii: Bool { return...

View Article

Browsing index pages (8 articles)


Latest Images