From Newsgroup: comp.editors
On 2026-04-01 16:26, DFS wrote:
On 3/31/2026 8:19 PM, Janis Papanagnou wrote:
Though on a second view I've asked
myself whether a word count could simply be determined by the
white-space separators.
number of spaces (using isspace()) + 1 is the standard I would think.
This quasi-formal expression is misleading. Depending on whether you
consider leading and trailing spaces on the line or not, and whether
single spaces are expressed by that function or sequences of spaces.
A regular expression is probably better to express what a "word" is;
maybe, say, /[^[:space:]]+/ . (This implies also "words" like *$%&!,
4GL, etc., besides the examples from the original post.)
If it's so simple I wonder what these
other editors do to show as reported such a broken behavior.
Microsoft Word 2003 reports 223 words.
I don't have the context available here, so I cannot tell whether MS
Word does that right or not. (My experiences with the quality of MS
products isn't that good, though. YMMV.) Vim, for example, counts it
correctly. (That's what's primarily important for me.)
Janis
--- Synchronet 3.21f-Linux NewsLink 1.2