Fix words in a Sentence

I have a number of text paragraphs… However the text is all UPPERCASE… I need some way to convert it to proper upper/lower case… This isn’t TITLECASE…

For example :

NOW YOU TRY THIS ONE.  THIS ONE SHOULD BE EASY I THINK.

Should become

Now you try this one. This one should be easy I think.

I guess I could split by word… and titlecase the first word, and any word where the previous doesn’t have a “period”…

Ok… this works :slight_smile:

var v : [String] = Split(action," ")
for j in(0...v.count-1) {
   if Left(v[j],1) == "'" || v[j]=="I" { continue }
   if j==0 { v[j]=v[j].Titlecase(); continue }
   if [".",";",":","!"].contains(Right(v[j-1],1)) { v[j]=v[j].Titlecase(); continue }
   v[j]=v[j].lowercased()
}
textBox.text = Join(v," ")