Splitting a string with multiple spaces

前端 未结 6 573
别那么骄傲
别那么骄傲 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

    This worked for me.

    s.split(/\s+/)
    

    var foo = "first     middle  last";
    
    console.log(foo.split(/\s+/));

提交回复
热议问题