I am trying to return only the text within the first
tags, stripping out the tags themselves...
The HTML is all within a string from an API, so I am escaping it in a React app, but I want to strip out the HTML to teaser a paragraph. Will update post.
"content": {
"rendered": "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>\n",
"protected": false
},
looking at other threads, the below should work, but I don't know how to populate the 2nd arg to replace with the content of the p tags:
string.replace(/<p>(.*?)<\/p>/);
Also, is there a way to limit it to the first paragraph if there is?
Thank you