Search This Blog

2023/07/25

Split string over multiple white spaces

 var sentence = " I am sangram desai. "

var arr = sentence.trim().split(/\s+/)
console.log(arr)

output:

[ 'I', 'am', 'sangram', 'desai.' ]

No comments:

Post a Comment