I have a use case where the user could paste something in a text area and I'd like to split them based on the following use cases:
How can I make sure I can catch comma space, comma new line, newline from the string? Any regex would be helpful.
I could do
"1, 2, 3".split(', ') // returns [1,2,3] "1,\n2,\n3,\n".split(',\n') // [1,2,3] "1\n2\n3\n".split('\n') // [1,2,3]
How do i account all three cases into one? Can we sanitize the input somehow and just return the array?
Would really appreciate some help here.