I have a string composed of words, some of which contain punctuation, which I would like to remove, but I have been unable to figure out how to do this.
For example if I
Xcode 11.4 • Swift 5.2 or later
extension StringProtocol { var words: [SubSequence] { split(whereSeparator: \.isLetter.negation) } }
extension Bool { var negation: Bool { !self } }
let sentence = "Hello, this : is .. a string?" let words = sentence.words // ["Hello", "this", "is", "a", "string"]