iOS iOS - 1 year ago 66
Swift Question

Replace all characters in a String in Swift

Just trying to do a play around with Swift String. I want to replace all the characters in a String to a blank space.

inputString = "This is a String"

outputString = " "

How could I achieve this in swift?


Another way:

let outputString = inputString.stringByReplacingOccurrencesOfString("[^\\s]",
                    withString: " ", 
                       options: .RegularExpressionSearch, 
                         range: Range(inputString.startIndex..<inputString.endIndex))