Java - Split and trim in one shot

后端 未结 8 1029
鱼传尺愫
鱼传尺愫 2020-12-13 23:25

I have a String like this : String attributes = \" foo boo, faa baa, fii bii,\" I want to get a result like this :

String[] result = {\"foo boo\         


        
8条回答
  •  情话喂你
    2020-12-14 00:10

    String result[] = attributes.trim().split("\\s*,[,\\s]*");
    

    previously posted here: https://blog.oio.de/2012/08/23/split-comma-separated-strings-in-java/

提交回复
热议问题