String str = "goOd gooD stUdy dAy dAy up";
Matcher m = Pattern.compile("(^| )([a-z])([a-zA-Z]*)").matcher(str);
StringBuffer sb = new StringBuffer();
while (m.find()) {
m.appendReplacement(sb, "$1" + m.group(2).toUpperCase() + "$3");
}
System.out.println(sb);
GoOd GooD StUdy DAy DAy Up
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |