Can you pass several options as the argument to .split? Trying to get or/and behavior.
Asked
Active
Viewed 80 times
1
Yevgen Gorbunkov
- 14,071
- 3
- 15
- 36
bib
- 29
- 4
-
1Using 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
-
1Does 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 Answers
1
`Hello World!\nBye World!`.split(/ |\n/); // ["Hello", "World!", "Bye", "World!"]
GirkovArpa
- 3,841
- 4
- 7
- 33