Giving the following string...
"Here is my very _special string_ with {different} types of _delimiters_ that might even {repeat a few times}."
... how to split it into an array using the 2 delimiters ("_", "{ and }") but also keeping the delimiters in each element of the array?
The goal is:
[
"Here is my very ",
"_special string_",
" with ",
"{different}",
" types of ",
"_delimiters_",
"that might even ",
"{repeat a few times}",
"."
]
My best bet was:
let myText = "Here is my very _special string_ with {different} types of _delimiters_ that might even {repeat a few times}."
console.log(myText.split(/(?=_|{|})/g))
as you see, it fails to reproduce the desirable array.