I'm trying to split strings into an array if there is a semicolon ";" or a dot "." or a colon ":".
The problem is, I would like the split to happen right after the separator, not before it. This code is working otherwise, but the separator is in the beginning of each element in the array. How can I make the separator become the last character in the array element?
const arrayForSplitText = myString.split((/(?=[.;:])/gi));
Example:
myString = "Hello there. I would like this: split me with the separators at the end of each element."
current result:
["Hello there", ". I would like this", ": split me with the separators at the end of each element", "."]
desired result:
["Hello there.", "I would like this:", "split me with the separators at the end of each element."]