It's a bit problematic to use a regular expression to clean up tags. Imagine you are using < in the text, because you are describing an equation; while that will only invalidate the result of your calculation, it's still considered bad practice.
A fast virtual DOM parser like linkedom will allow you to get document.body.textContent and run the calculation on that.
Also, if you split by \s, you may get non-existing words if there are multiple spaces; better split by \W+.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It's a bit problematic to use a regular expression to clean up tags. Imagine you are using
<
in the text, because you are describing an equation; while that will only invalidate the result of your calculation, it's still considered bad practice.A fast virtual DOM parser like linkedom will allow you to get document.body.textContent and run the calculation on that.
Also, if you split by
\s
, you may get non-existing words if there are multiple spaces; better split by\W+
.