Home > Enterprise >  Split a string with HTML <br> tag into multiline string
Split a string with HTML <br> tag into multiline string

Time:05-20

I've a string that contains html break tag to split the string as I would like to split the string into multiple lines but it doesn't seem to render the string as multi-line in UI. How can I achieve the following?

testString = "This is line one<br>This is line two<br>This is line three"

Expected Output:

This is line one
This is line two
This is line three

I read about dangerouslysettinginnerHTML but don't want to use it in my code. As far as split is concerned what I did was I tried

text.split('<br>').map(each => each   <br>)

but that didn't work. Any hint or help would be appreciated.

CodePudding user response:

The easiest way to do this outside of Edit tender-taussig-uc6y50

  • Related