[HELP] Regex question on my random quote machine

Hello Fellow Campers!!

I ran into a slight issue while building my random quote machine. The API that I am using, https://quotesondesign.com/api-v4-0/ , places paragraph tags in its JSON data, specifically around the quote (“content” property). This wasn’t an issue until I wanted to take the quote and tweet it out. When I would send the quote to twitter it would include the “p” tags in the tweet.

To overcome this I stored the data with .replace() using Regex to filter out the “p” tags. However I couldn’t figure out how to remove both the opening and the closing tags in the same .replace() function. To get around this I split the quote into two variables and used a replace function twice- the first to remove the opening tag and the second to remove the closing tag.

My Question: how do I write my Regex to capture both the opening and closing paragraph tags without having to write them twice. I have specified where the question starts in the javascript section of my codepen with ### FREE CODE CAMP QUESTION STARTS HERE ###.

codepen link:

@ArielLeslie I summon you!


1 Like

@ArielLeslie I love you.

Helpful and funny response :smiley: