I would like to capitalize the first word of every sentence in a string. For example this string:
apple Park will run one of the largest on-site solar energy installations in the world. it is also the site of the world’s largest naturally ventilated building.
Should become:
Apple Park will run one of the largest on-site solar energy installations in the world. It is also the site of the world’s largest naturally ventilated building.
I also would like that the capitalization don't happens when a world already has a capital letter among its characters, for example:
iPad is a mobile device.
Remains
iPad is a mobile device.
For the first part of this task, I could use this code by rintaro:
let str = "someSentenceWith UTF text İŞğĞ. anotherSentenceğüÜğ"
var result = ""
str.uppercaseString.enumerateSubstringsInRange(str.characters.indices, options: .BySentences) { (sub, _, _, _) in
result += String(sub!.characters.prefix(1))
result += String(sub!.characters.dropFirst(1)).lowercaseString
}
print(result)
But its for Swift 2 and don't work for Swift 3.