Splitting a string with multiple spaces

前端 未结 6 562
别那么骄傲
别那么骄傲 2020-12-01 02:53

I want to split a string like

\"first     middle  last\" 

with String.split(). But when i try to split it I get



        
6条回答
  •  攒了一身酷
    2020-12-01 03:20

    Since split() uses regular expressions, you can do something like s.split("\\s+") to set the split delimiter to be any number of whitespace characters.

提交回复
热议问题