import Foundation
let pattern = #"(?m)^\s*[[:upper:]][[:alpha:]]*|.*?([[:upper:]][[:alpha:]]*|$)"#
let regex = try! NSRegularExpression(pattern: pattern, options: .anchorsMatchLines)
let testString = #"""
Words of sentences (that are preceeded by a Space and a Period), and also ignoring the first word of the cell
How to extract Words with Uppercase first letter only
With
"""#
let stringRange = NSRange(location: 0, length: testString.utf16.count)
let substitutionString = #"\n"#
let result = regex.stringByReplacingMatches(in: testString, range: stringRange, withTemplate: substitutionString)
print(result)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Swift 5.2, please visit: https://developer.apple.com/documentation/foundation/nsregularexpression