I have a string like below -
var text="this is <b>a sample</b> long text. <i>Sample <b>tex</b>t <u>containing</u> some</i> bold underlined and it<i>alics wo</i>rds."
I want a JavaScript array like this
var textArr = [
"this is ",
"<b>a sample</b>",
" long text. ",
" ",
"<i>Sample</i>",
" ",
"<i><b>tex</b></i>",
"<i>t</i>",
" ",
"<i><u>containing</u></i>",
" ",
"<i>some</i>",
" bold underlined and it",
"<i>alics wo</i>",
"rds"
];
I need this because I need each fragment so that I can create that formatted canvas text object and place them on canvas. Can anyone please help me on this?