let titles = this.state.posts.slice(0, 3).map(function(title, index) {
let regex = /<style(.+?)\/style>/gm;
let res = regex.exec(title.content.rendered);
console.log(res);
return (
<div key={index}>
<p className="title has-text-black">{title.title.rendered}</p>
<div className=" has-text-black">{title.content.rendered.replace(regex, '')}</div>
</div>
);
});
I try to fetch some posts from wordpress rest api, the content.rendered return a string include html, style tags etc. And i want it just a pure text with no html tags. I wonder why the regex above won't work? I did try other regex, it works, but not this anything-in-style-tags-remover regex.