Share this page 

Apply proper uppercase and lowercase on a StringTag(s): String/Number

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StringUtils {
  private StringUtils () {}

  public static String upperCaseWordFirst(String str) {
    StringBuffer sb = new StringBuffer();
    Matcher m = Pattern.compile
    while (m.find()) {
            + ;
    str = m.appendTail(sb).toString();
    return str;

  public static void main(String [] args)  {
    System.out.println(StringUtils.upperCaseWordFirst("  #600how-to"));
    System.out.println(StringUtils.upperCaseWordFirst("ELVis preSLEY"));
    System.out.println(StringUtils.upperCaseWordFirst("john o'connor & steeve mcmillan"));
     output :

     Elvis Presley
     John O'Connor & Steeve Mcmillan

     for the "mcmillan", well this may be not enough and you will need
     to process it as a special case if needed...