Here is a code snippet in Javascript that comes from Nicholas C. Zakas' renowned book on Javascript:
var text = “apple,banana,orange,strawberry”;
var fruits1 = text.split(“,”); //[“apple”, “banana”, “orange”, “strawberry”]
var fruits2 = text.split(/[^\,]+/); //[“”, “,”, “,” , “,”, “”]
The function of the second split
method can be quite perplexing to comprehend.
Is there anyone who can provide an explanation?