I need a regex expression to separate each word and br

July 29   regex 0 0 Views
Advertisement

What I need is super straight forward however I simply cannot figure it out. I am using regex101.com to try and nail down the correct regex but nothing seems to work.

Basically what I need is to create a list of words and <br> tags in an array.

It could be any of these <br> tags, <br>, <br/>, <br >, <br />

So for Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br /><br />Duis eu metus porttitor, maximus elit vitae, sodales leo.

I need an expression that will give me

["Lorem ", "ipsum ", "dolor ", "sit ", "amet, ", "consectetur ", "adipiscing ", "elit.", "<br />", "<br />", "Duis ", "eu ", "metus ", "porttitor, ", "maximus ", "elit ", "vitae, ", "sodales ", "leo. "] 

So far all I have is /\S+\s+/g but this is only looking for spaces.

Advertisement

Replay

Tags: regex
PC site About | Contact

©2016 avrocks.com all rights reserved

processed in 0.109 (s). 5 q(s)