public static String capitalizeNameTitleAbbrvs(String line){
  String result=line;
  for (  String title : new String[]{"dr","miss","mr","mrs","ms","prof"}) {
    result=result.replaceAll("\\b" + title + "\\b",Character.toUpperCase(title.charAt(0)) + title.substring(1));
  }
  result=result.replaceAll("\\b" + "phd" + "\\b","PhD");
  result=result.replaceAll("\\b" + "mphil" + "\\b","MPhil");
  return result;
}

public static String capitalizeNameTitleAbbrvs ( String line ) { String result = line ; for ( String title : new String [ ] { "dr" , "miss" , "mr" , "mrs" , "ms" , "prof" } ) { result = result . replaceAll ( "\\b" + title + "\\b" , Character . toUpperCase ( title . charAt ( 0 ) ) + title . substring ( 1 ) ) ; } result = result . replaceAll ( "\\b" + "phd" + "\\b" , "PhD" ) ; result = result . replaceAll ( "\\b" + "mphil" + "\\b" , "MPhil" ) ; return result ; }
capitalize the first character of the titles of names : mr mrs ms miss dr prof
