public class RegexTest { public static void main(String[] args) { String s = "AAccpHelloWorldHH"; String[] ss = s.split("(?<!^)(?=[A-Z])"); for(int i = 0 ;i < ss.length; i ++){ System.out.println(ss[i]); } } }
以上方法兼容首字母是小写的,不兼容含有空格的字符串
public class RegexTest { public static void main(String[] args) { String s = "AAccpHelloWorldHH"; String[] ss = s.split("(?<!^)(?=[A-Z])"); for(int i = 0 ;i < ss.length; i ++){ System.out.println(ss[i]); } } }
以上方法兼容首字母是小写的,不兼容含有空格的字符串