title: How to capitalize first word in every sentence with Swift
body: <p>By taking into account of user locale, how can I capitalize the first word of each sentence in a paragraph? What I want to achieve is no matter the case inside the sentence, the first letter of each word will be uppercase and the rest will be lowercase. I can do only one sentence by first converting everything to lower case, then get first letter and make uppercase and finally add them up together. My question is different than <a href="https://stackoverflow.com/questions/29261218">How to capitalize each word in a string using Swift iOS</a> since I don't want to capitalize each word. I just want to capitalize the first word of each sentence. <code>capitalizedString</code> turns </p>
  
  <pre><code>"this is first sentence. this is second sentence."
  </code></pre>
  
  <p>to</p>
  
  <pre><code>"This Is First Sentence. This Is Second Sentence."
  </code></pre>
  
  <p>What I want is </p>
  
  <pre><code>"This is first sentence. This is second sentence."
  </code></pre>
  
  <p>My question is also different than <a href="https://stackoverflow.com/questions/27169581/capitalise-first-letter-of-every-sentence">Capitalise first letter of every sentence</a> Since @rintaro's code doesn't work on my below example. It keeps capital letters in original text intact. With @rintaro's code;</p>
  
  <p>before</p>
  
  <pre><code>"someSentenceWith UTF text İŞğĞ. anotherSentenceğüÜğ"
  </code></pre>
  
  <p>after</p>
  
  <pre><code>"SomeSentenceWith UTF text İŞğĞ. AnotherSentenceğüÜğ."
  </code></pre>
  
  <p>What I want to achieve,</p>
  
  <pre><code>"Somesentencewith utf text işğğ. Anothersentenceğüüğ." 
  </code></pre>
  
  <p>My code below can only do partial conversion.
  </p>
  
  <pre><code>var description = "someSentenceWith UTF text İŞğĞ. anotherSentenceğüÜğ"
  description = description.lowercaseStringWithLocale(NSLocale.currentLocale())
  let first = description.startIndex
  let rest = advance(first,1)..&lt;description.endIndex
  let capitalised = description[first...first].uppercaseStringWithLocale(NSLocale.currentLocale()) + description[rest]
  </code></pre>
  
  <p>I will really appreciate if you can please read my question carefully, since this is the third time I am editing the question. I am really sorry if I couldn't ask it clearly since I am not a native speaker. So even though @rintaro answered similar question, his answer doesn't solve my problem. @martin-r suggests a Objective-C answer which again doesn't solve the problem I have. There were another user eric something who also suggested another answer but deleted afterwards. I just can't understand why several people suggest different answer which doesn't answer my question.</p>