Skip to content Skip to sidebar Skip to footer

Remove Html From A String (in Json Response)

var json = { 'Item': { 'Items': { 'Body': '

Solution 1:

I think all you need is a simple regex to strip html style tags from the content. Try this.

str.replace(/<\/?[^>]+>/gi, '')

Solution 2:

This should do the magic http://jsfiddle.net/Ygfvp/ Anyway it won't strip the html comments

Solution 3:

If you're mapping Json using React, then you can just leave the html tags and put them to use.

Instead of:

<div>{el.content.rendered}</div>

Do this:

<divdangerouslySetInnerHTML={{__html:el.content.rendered}}></div>

Post a Comment for "Remove Html From A String (in Json Response)"