[Java] 纯文本查看 复制代码 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);
输出:
[Java] 纯文本查看 复制代码 GoOd GooD StUdy DAy DAy Up |