0

I am writing JSON API call where I am getting html string

ie:

"content":"<p>Being a designer is like being a porn star. 
You&#8217;re hot &#038; popular for a year or two, 
then everyone goes off and finds something new to screw around too.  <\/p>\n"

I need to get this string without HTML, so I am using this:

n = e.content.replace(/(<([^>]+)>)/gi, "")

but when in string is Right single quotation mark ’ &#8217; it will end the string.

Please, how can I filter/replace this quotation mark together with other symbols? When I added quotation mark, it stopped filtering everything.

Vlasta Po
  • 821
  • 1
  • 10
  • 12
  • Is the content always a single HTML tag containing the encoded text you wish to retrieve? – Aaron May 19 '17 at 13:29
  • *but when in string is Right single quotation mark ’ ’ it will end the string.* I don't understand this sentence. what do you mean? Anyway, the solution is to create a new element, set this as `innerHTML`, then take its `textContent`. –  May 19 '17 at 13:34
  • @torazaburo thank you very much, `textContent` solved it `x = document.getElementById("quote-content").textContent;` – Vlasta Po May 19 '17 at 14:03

0 Answers0