Java: Split string when an uppercase letter is found

前端 未结 7 974
醉梦人生
醉梦人生 2020-11-27 15:29

I think this is an easy question, but I am not able to find a simple solution (say, less than 10 lines of code :)

I have a String such as \"thisIs

7条回答
  •  时光取名叫无心
    2020-11-27 16:03

    Since String::split takes a regular expression you can use a look-ahead:

    String[] x = "thisIsMyString".split("(?=[A-Z])");
    

提交回复
热议问题