const escapeHTML = (str: string) =>
        str.replace(
          /[&<>'"]/g,
          tag =>
            ({
              '&': '&amp;',
              '<': '&lt;',
              '>': '&gt;',
              "'": '&#39;',
              '"': '&quot;'
            }[tag] || tag)
        );
      

      Typescript language logo
      Escape HTML

      Codiga's TypeScript Recipes

      Escapes a string for use in HTML.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.