Quantcast
Channel: How to remove special characters from string in Swift 2? - Stack Overflow
Browsing latest articles
Browse All 8 View Live

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 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 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 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

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 Ben Lin for How to remove special characters from string in Swift 2?

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

View Article

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
Browsing latest articles
Browse All 8 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>