To explain from my comment... Think of regular expressions as a way to nicely find patterns within Strings. In your case, the pattern is words (groups of letters) with other possible symbols (punctuation marks) in between.
Take the regex in my comment (which I've expanded a bit here), for example: ([,\.\:\"])*([A-Za-z0-9\']*)([,\.\:\"])*
In there, we have 3 groups. The first searches for any symbols (such as a leading quotation mark). The second is searching for letters, numbers, and an apostrophe (because people like to concatenate words, like "I'm"). and the third group searches for any trailing punctuation marks.
Edit to note: groups in the above are denoted by parentheses ( and ), while the [ and ] brackets denote acceptable characters for a search. So, for example, [A-Z] says that all upper case letters from A-Z are acceptable. [A-Za-z] lets you get both upper and lower, while [A-Za-z0-9] includes all letters and numbers from 0-9. Granted, there are shorthand versions to writing this, but those you'll discover down the road.
So now we have a way to separate all the words and punctuation marks, now you need to actually use it, doing something along the lines of:
func find(value: NSString) throws -> [NSString] { let regex = try NSRegularExpression(pattern: "([,\\.\\:\\\"])*([A-Za-z0-9\\']*)([,\\.\\:\\\"])*") // Notice you have to escape the values in code let results = regex.matches(in: value, range: NSRange(location: 0, length: nsString.length)) return results.map({ value.substring(with: $0.range) }).filter({ $0 != nil }) }
That should give you each non-nil group found within the String value you supply to the method.
Granted, that last filter method may not be necessary, but I'm not familiar enough with how Swift handles regex to know for sure.
But that should definitely point you in the right direction...
Cheers~
([A-Za-z\']*)([,\.])*, then the optional subgroups of [0, 1] would contain your parts (e.g. 'Hello', ',') and then you could run a flatMap on all of the non-nil groups to merge them into a single array of separated strings