Html entities to text string - React Native Solution

After developing a simple quiz app, I came across a challenge to solve a bunch html entity text's gotten from my api. So this tutorial is for you, incase you have such an issue.

example of html entity text within a sentence

Some of the " Fallen Empires " cards from " Magic: The Gathering " were misprinted on the backs of which other card game?

You can see what I mean in the above question. Now below is the solution and usage 

var entities: any = {
  amp: "&",
  apos: "'",
  "#x27": "'",
  "#x2F": "/",
  "#39": "'",
  "#47": "/",
  lt: "<",
  gt: ">",
  nbsp: " ",
  quot: '"',

export function decodeHTMLEntities(text: any) {
  return text.replace(/&([^;]+);/gm, function (match: any, entity: any) {
    return entities[entity] || match;

and finally use it on any of your react native project, that will solve it for you.