I am looking for a way to split this array of strings:
["this", "is", "a", "test", ".", "I", "wonder", "if", "I", "can", "parse", "this",
"text", "?", "Without", "any", "errors", "!"]
into groups ending with punctuation:
[
["this", "is", "a", "test", "."],
["I", "wonder", "if", "I", "can", "parse", "this", "text", "?"],
["Without", "any", "errors", "!"]
]
Is there an easy way to do this? What is the most sensible approach to iterating an array, adding each index to a temporary array and adding this temporary array to the container array when punctuation is detected?
I was thinking about using sliceor map, but I can't figure out if this is possible or not.