1

Can you pass several options as the argument to .split? Trying to get or/and behavior.

Yevhen Horbunkov
  • 14,965
  • 3
  • 20
  • 42
bib
  • 31
  • 4
  • 1
    Using a regex: `"abc 444\n555".split(/\s|\n/)` – wiomoc Jun 11 '20 at 21:09
  • https://stackoverflow.com/questions/650022/how-do-i-split-a-string-with-multiple-separators-in-javascript – QurakNerd Jun 11 '20 at 21:11
  • 2
    @wiomoc `\s|\n` is redundant: `\s` already includes `\n`. You may have meant `( |\n)` or `[ \n]`. – ggorlen Jun 11 '20 at 21:12
  • 1
    Does this answer your question? [How do I split a string with multiple separators in javascript?](https://stackoverflow.com/questions/650022/how-do-i-split-a-string-with-multiple-separators-in-javascript) – user120242 Jun 11 '20 at 21:33

1 Answers1

1
`Hello World!\nBye World!`.split(/ |\n/); // ["Hello", "World!", "Bye", "World!"]
GirkovArpa
  • 4,427
  • 4
  • 14
  • 43