Is there a reason the analyzeNote function doesn't use word boundaries?
analyzeNote() {
var s = this.state.note.content.text;
s = s.replace(/(^\s*)|(\s*$)/gi,"");//exclude start and end white-space
s = s.replace(/[ ]{2,}/gi," ");//2 or more space to 1
s = s.replace(/\n /,"\n"); // exclude newline with a start spacing
let wordCount = s.split(' ').length;
this.setState({wordCount: wordCount});
}
Would become:
analyzeNote() {
// Count all word boundaries in the note text and divide by 2
// to get the word count:
let wordCount = this.state.note.content.text.match(/\b/gm).length / 2;
this.setState({wordCount: wordCount});
}
If this is OK, I'll set up PRs to change it here and in the documentation.
Is there a reason the
analyzeNotefunction doesn't use word boundaries?Would become:
If this is OK, I'll set up PRs to change it here and in the documentation.