Currently, I am attempting to count words within the Summernote editor using Angular. While I have successfully created a service for counting words, it seems to be ineffective when encountering new lines.
Here is an example of the text:
Hult International 23
s
e
r
t
My attempt at solving this issue has been as follows:
if (text && text.length > 0) {
text = text.replace(/<(?:.|\n)*?>/gm, '').replace(/&nbsp;/g, '').replace(/ /g, '').trim();
return text.length ? text.split(/\s+/).length : 0;
}
You can also view the problem in the image linked here.