I have an html string and I want to get the length of words:
const myHtml = "<p>First paragraph</p><div>First div</div>";
const wordsCount = myHtml.split(' ').length; // but this will count the entire string
I need to count only words, without html elements as <p> or <div>.
I saw dangerouslySetInnerHTML is used only for to load the string as html. How I can remove all tags? Should I use some regex like removing all elements between < and > ?