I have the following regular expression:
(</?[a-z][a-z0-9]*[^<>]*>)
I have the following text:
<DIV><P class='abc'>Hello <B>Mister</B>! How are you >..< doing? </P>
<I>I'm good</I></DIV>
Now I'd like to split the text per tag:
<DIV>
<P class='abc'>
Hello
<B>
Mister
</B>
! How are you >..< doing?
</P>
<I>
I'm good
</I>
</DIV>
How can I do this with Javascript regex?
Is was able to get it to work but had to start over because javascript doesn't support lookbehinds.
(basically split on html tags and keep the delimiters)
Edit:
My goal with this is to use html to store formatting. I want to feed the html above to a javascript object. The javascript object separates the formatting from the text and does action A for formatting objects and action B for regular text.
I know it sounds a bit vague, but I don't want to reveal too much about the project.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…