Split string into 2 strings based on a delimiter

后端 未结 3 1069
迷失自我
迷失自我 2020-12-17 17:48

Does anybody know if there is a solid library based method to achieve the following.

Say I have the string

\"name1, name2, name3, name4\" 
         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-17 18:22

    String s = "hello=goodmorning,2,1"
    String[] str = s.split("=");  //now str[0] is "hello" and str[1] is "goodmorning,2,1"
    String str1 = str[0];  //hello
    String[] str2 = str[1].split(",");  //now str2[0] is "goodmorning" and str2[1] is "2,1"
    

提交回复
热议问题