I would like to split this text. I am trying to do it with JavaScript regular expression.
(1) Really not. (2) Uh huh. (3) Behold Prince (4) are key in his natural element, cowering at the mercy of the women in his life. (5) See me perhaps you'd like to spout with my daughters and teach them some combination. (6) No doubt you are the best teacher, your majesty. (7) It is my daughter's that teach me in the languages of the modern world, for instance.
I would like to parse it to groups of fragments. I am looking for one of these results.
[
[1, "Really not."],
[2, "Uh huh."],
[3, "Behold Prince"],
]
[
{id: 1, text: "Really not."},
{id: 2, text: "Uh huh."},
{id: 3, text: "Behold Prince"},
]
I use this pattern.
/\(([0-9])\){1,3}(.+?)\(/g
Could you help me, please? What pattern should I use to split the text properly?
Thank you in advance!
You can use regex and string.matchAll function in javascript to do what you want
I updated my answer using The fourth bird's regex because it is alot cleaner than the regex I wrote.