JavaScript Split String по нескольким символам
let string = "Hello awesome, world!"
string.split(/[\s,]+/)
// Hello,awesome,world!
Undefined
let string = "Hello awesome, world!"
string.split(/[\s,]+/)
// Hello,awesome,world!
You can pass a regex into JavaScript's split() method. For example:
"1,2 3".split(/,| /)
["1", "2", "3"]
Or, if you want to allow multiple separators together to act as one only:
"1, 2, , 3".split(/(?:,| )+/)
["1", "2", "3"]