Here is a method in Java that capitalizes the first letter of every sentence found. This is made possible through the use of regular expressions (Regex).

The regex string in this method capitalizes the first letter found after either a period, question mark or exclamation point. The number of space characters in between does not matter so if you have 2 or 3 spaces after a period, the very first alphabet character it can find will be capitalized.

The drawback of this regular expression is that the very first letter of the string does not get capitalized. Hence, I added a little workaround code after the regex operation to make sure the first letter of the String is capitalized.

Related Posts Plugin for WordPress, Blogger...