Android examples for java.util.regex:Character Pattern
capitalize First Letter by regular expression
import android.util.Log; import java.io.UnsupportedEncodingException; public class Main{ public static String capitalizeFirstLetter(String input) { input = input.toLowerCase();//from w ww . j a v a 2 s . co m String[] words = input.split("\\s+"); StringBuilder sb = new StringBuilder(input.length()); if (words[0].length() > 0) { sb.append(Character.toUpperCase(words[0].charAt(0))).append( words[0].substring(1, words[0].length())); for (int ii = 1; ii < words.length; ii++) { sb.append(" "); sb.append(Character.toUpperCase(words[ii].charAt(0))) .append(words[ii].substring(1, words[ii].length())); } } return sb.toString(); } }