How to remove special characters from string in Swift 2?

前端 未结 5 2094
青春惊慌失措
青春惊慌失措 2020-12-02 20:07

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 removeSpecialCharsFr         


        
5条回答
  •  忘掉有多难
    2020-12-02 20:47

    I think that a cleaner solution could be this approach:

    extension String {
        var alphanumeric: String {
            return self.components(separatedBy: CharacterSet.alphanumerics.inverted).joined().lowercased()
        }
    }
    

提交回复
热议问题